فهرست منبع

feat(products): adiciona quantidade

ebagabee 1 ماه پیش
والد
کامیت
437fe2dc96

+ 2 - 0
app/Http/Requests/ProductRequest.php

@@ -12,11 +12,13 @@ public function rules(): array
             'name'        => 'sometimes|string|max:255',
             'description' => 'sometimes|nullable|string|max:2000',
             'price_sale'  => 'sometimes|numeric|min:0',
+            'quantity'    => 'sometimes|integer|min:0',
         ];
 
         if ($this->isMethod('POST')) {
             $rules['name']       = 'required|string|max:255';
             $rules['price_sale'] = 'required|numeric|min:0';
+            $rules['quantity']   = 'required|integer|min:0';
         }
 
         return $rules;

+ 1 - 0
app/Http/Resources/ProductResource.php

@@ -22,6 +22,7 @@ public function toArray(Request $request): array
             'name'        => $this->name,
             'description' => $this->description,
             'price_sale'  => $this->price_sale,
+            'quantity'    => $this->quantity,
             'created_at'  => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
             'updated_at'  => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
         ];

+ 22 - 0
database/migrations/2026_05_14_000002_add_quantity_to_products_table.php

@@ -0,0 +1,22 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    public function up(): void
+    {
+        Schema::table('products', function (Blueprint $table) {
+            $table->unsignedInteger('quantity')->default(0)->after('price_sale');
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('products', function (Blueprint $table) {
+            $table->dropColumn('quantity');
+        });
+    }
+};

+ 1 - 142
database/seeders/DeveloperTestSeeder.php

@@ -2,153 +2,12 @@
 
 namespace Database\Seeders;
 
-use App\Models\Product;
 use Illuminate\Database\Seeder;
 
 class DeveloperTestSeeder extends Seeder
 {
     public function run(): void
     {
-        $this->seedProducts();
-    }
-
-    private function seedProducts(): void
-    {
-        $products = [
-            [
-                'name'               => 'Apostila Nível 1',
-                'sku'                => 'AP-NV1',
-                'barcode'            => '7890001000001',
-                'price_cost'         => 18.00,
-                'price_sale'         => 35.00,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.300,
-                'length'             => 29.7,
-                'height'             => 21.0,
-            ],
-            [
-                'name'               => 'Apostila Nível 2',
-                'sku'                => 'AP-NV2',
-                'barcode'            => '7890001000002',
-                'price_cost'         => 18.00,
-                'price_sale'         => 35.00,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.300,
-                'length'             => 29.7,
-                'height'             => 21.0,
-            ],
-            [
-                'name'               => 'Apostila Nível 3',
-                'sku'                => 'AP-NV3',
-                'barcode'            => '7890001000003',
-                'price_cost'         => 18.00,
-                'price_sale'         => 35.00,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.300,
-                'length'             => 29.7,
-                'height'             => 21.0,
-            ],
-            [
-                'name'               => 'Kit Material Didático Básico',
-                'sku'                => 'KIT-MAT-BAS',
-                'barcode'            => '7890001000010',
-                'price_cost'         => 45.00,
-                'price_sale'         => 89.90,
-                'measure_unit'       => 'KIT',
-                'kit'                => true,
-                'visible_franchisee' => true,
-                'weight'             => 0.800,
-                'length'             => 30.0,
-                'height'             => 22.0,
-            ],
-            [
-                'name'               => 'Kit Material Didático Completo',
-                'sku'                => 'KIT-MAT-COMP',
-                'barcode'            => '7890001000011',
-                'price_cost'         => 90.00,
-                'price_sale'         => 169.90,
-                'measure_unit'       => 'KIT',
-                'kit'                => true,
-                'visible_franchisee' => true,
-                'weight'             => 1.500,
-                'length'             => 30.0,
-                'height'             => 22.0,
-            ],
-            [
-                'name'               => 'Caderno de Atividades',
-                'sku'                => 'CAD-ATI',
-                'barcode'            => '7890001000020',
-                'price_cost'         => 12.00,
-                'price_sale'         => 24.90,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.200,
-                'length'             => 29.7,
-                'height'             => 21.0,
-            ],
-            [
-                'name'               => 'Livro do Aluno — Ginástica do Cérebro',
-                'sku'                => 'LV-ALUNO-GC',
-                'barcode'            => '7890001000030',
-                'price_cost'         => 32.00,
-                'price_sale'         => 59.90,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.450,
-                'length'             => 23.0,
-                'height'             => 16.0,
-            ],
-            [
-                'name'               => 'Camiseta Ginástica do Cérebro',
-                'sku'                => 'CAM-GC',
-                'barcode'            => '7890001000040',
-                'price_cost'         => 20.00,
-                'price_sale'         => 49.90,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.200,
-                'length'             => 30.0,
-                'height'             => 20.0,
-            ],
-            [
-                'name'               => 'Pasta do Aluno',
-                'sku'                => 'PAST-ALUNO',
-                'barcode'            => '7890001000050',
-                'price_cost'         => 5.00,
-                'price_sale'         => 12.90,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => true,
-                'weight'             => 0.100,
-                'length'             => 33.0,
-                'height'             => 23.0,
-            ],
-            [
-                'name'               => 'Certificado de Conclusão',
-                'sku'                => 'CERT-CONCL',
-                'barcode'            => '7890001000060',
-                'price_cost'         => 2.00,
-                'price_sale'         => 5.00,
-                'measure_unit'       => 'UN',
-                'kit'                => false,
-                'visible_franchisee' => false,
-                'weight'             => 0.050,
-                'length'             => 29.7,
-                'height'             => 21.0,
-            ],
-        ];
-
-        foreach ($products as $product) {
-            Product::firstOrCreate(['sku' => $product['sku']], $product);
-        }
+        //
     }
 }

+ 0 - 13
database/seeders/ProductSeeder.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace Database\Seeders;
-
-use Illuminate\Database\Seeder;
-
-class ProductSeeder extends Seeder
-{
-    public function run(): void
-    {
-        // Data moved to DeveloperTestSeeder
-    }
-}