diff --git a/app/Http/Controllers/Api/ProductoController.php b/app/Http/Controllers/Api/ProductoController.php index 246c319..e196fa0 100644 --- a/app/Http/Controllers/Api/ProductoController.php +++ b/app/Http/Controllers/Api/ProductoController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Filtros\FiltroDeProducto; +use App\Http\Resources\ProductoResource; use App\Producto; class ProductoController extends Controller @@ -18,7 +19,7 @@ class ProductoController extends Controller */ public function index(FiltroDeProducto $filtros, Request $request) { - return Producto::filtrar($filtros)->paginate(Producto::getPaginar($request)); + return ProductoResource::collection(Producto::filtrar($filtros)->paginate(Producto::getPaginar($request))); } /** diff --git a/app/Http/Resources/ProductoResource.php b/app/Http/Resources/ProductoResource.php new file mode 100644 index 0000000..b0210f3 --- /dev/null +++ b/app/Http/Resources/ProductoResource.php @@ -0,0 +1,29 @@ + $this->id, + 'nombre' => $this->nombre, + 'precio' => $this->precio, + 'categoria' => $this->categoria, + 'proveedor' => optional($this->proveedor)->nombre, + 'imagen' => optional($this->poster)->url(), + 'descripcion' => $this->descripcion, + 'apto_veganxs' => $this->apto_veganxs, + 'apto_caliacxs' => $this->apto_caliacxs + ]; + } +} diff --git a/database/seeds/ProductoSeeder.php b/database/seeds/ProductoSeeder.php index 923d89d..c6e8494 100644 --- a/database/seeds/ProductoSeeder.php +++ b/database/seeds/ProductoSeeder.php @@ -2,6 +2,7 @@ use Illuminate\Database\Seeder; use League\Csv\Reader; +use App\Proveedor; class ProductoSeeder extends Seeder { @@ -23,7 +24,10 @@ class ProductoSeeder extends Seeder $toInsert[] = [ 'categoria' => $registro['categoria'], 'nombre' => $registro['producto'], - 'precio' => $registro['precio'] + 'precio' => $registro['precio'], + 'proveedor_id' => isset($registro['proveedor']) ? Proveedor::firstOrCreate([ + 'nombre' => $registro['proveedor'] + ])->id : null ]; } diff --git a/public/css/app.css b/public/css/app.css index 6ad3b7e..1a9b028 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -1,3 +1,8 @@ p.navbar-item:empty { display: none; -} \ No newline at end of file +} + +.breadcrumb a { + color: #cc0f35; +} + diff --git a/public/js/app.js b/public/js/app.js index 16e7d43..38d9e2f 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,6 +1,8 @@ +window.Event = new Vue(); + Vue.component('nav-bar', { template: ` -