Agregado metodo y ruta para obtener categorias
This commit is contained in:
parent
23af6ccd61
commit
88af33d998
2 changed files with 6 additions and 6 deletions
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
use App\Filtros\FiltroDeProducto;
|
use App\Filtros\FiltroDeProducto;
|
||||||
use App\Http\Resources\ProductoResource;
|
use App\Http\Resources\ProductoResource;
|
||||||
use App\Producto;
|
use App\Producto;
|
||||||
|
@ -20,4 +20,8 @@ class ProductoController extends Controller
|
||||||
return new ProductoResource($producto);
|
return new ProductoResource($producto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function categorias()
|
||||||
|
{
|
||||||
|
return Producto::all()->pluck('categoria')->unique()->flatten();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\GrupoDeCompra;
|
|
||||||
use App\Producto;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -39,9 +37,7 @@ Route::middleware('api')->group(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
//@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
|
//@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
|
||||||
Route::get('/categorias', function() {
|
Route::get('/categorias', 'Api\ProductoController@categorias');
|
||||||
return Producto::all()->pluck('categoria')->unique()->flatten();
|
|
||||||
});
|
|
||||||
|
|
||||||
//@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
|
//@TO DO -> esta ruta debe estar en middleware de auth y/o subpedido
|
||||||
Route::prefix('productos')->group(function () {
|
Route::prefix('productos')->group(function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue