diff --git a/app/Http/Controllers/Bo/ProductsController.php b/app/Http/Controllers/Bo/ProductsController.php index 704fbe3..79af53a 100644 --- a/app/Http/Controllers/Bo/ProductsController.php +++ b/app/Http/Controllers/Bo/ProductsController.php @@ -493,6 +493,8 @@ class ProductsController extends Controller 'product_id' => $product_id, ]); + $anifoodProduct->composition = $request->composition; + $anifoodProduct->servings = $request->servings; $anifoodProduct->save(); } @@ -506,6 +508,9 @@ class ProductsController extends Controller 'product_id' => $product_id, ]); + $garmentProduct->size = $request->size; + $garmentProduct->color = $request->color; + $garmentProduct->material = $request->material; $garmentProduct->save(); } diff --git a/app/Models/Product.php b/app/Models/Product.php index a2678a2..b4e121b 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -245,6 +245,21 @@ class Product extends Model implements Buyable return $this->hasOne(FoodProduct::class, 'product_id'); } + public function anifoodProduct() + { + return $this->hasOne(AnifoodProduct::class, 'product_id'); + } + + public function toolProduct() + { + return $this->hasOne(ToolProduct::class, 'product_id'); + } + + public function garmentProduct() + { + return $this->hasOne(GarmentProduct::class, 'product_id'); + } + //relationship to associated products diff --git a/database/migrations/2021_05_25_100049_add_fields_to_anifood_products_table.php b/database/migrations/2021_05_25_100049_add_fields_to_anifood_products_table.php new file mode 100644 index 0000000..bdceea1 --- /dev/null +++ b/database/migrations/2021_05_25_100049_add_fields_to_anifood_products_table.php @@ -0,0 +1,34 @@ +text('composition')->after('product_id'); + $table->unsignedInteger('servings')->after('composition')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('anifood_products', function (Blueprint $table) { + $table->dropColumn('composition'); + $table->dropColumn('servings'); + }); + } +} diff --git a/database/migrations/2021_05_25_101151_add_fields_to_garment_products_table.php b/database/migrations/2021_05_25_101151_add_fields_to_garment_products_table.php new file mode 100644 index 0000000..07fd645 --- /dev/null +++ b/database/migrations/2021_05_25_101151_add_fields_to_garment_products_table.php @@ -0,0 +1,36 @@ +string('size')->after('product_id'); + $table->string('color')->after('size'); + $table->string('material')->after('color'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('garment_products', function (Blueprint $table) { + $table->dropColumn('material'); + $table->dropColumn('color'); + $table->dropColumn('sersizevings'); + }); + } +} diff --git a/resources/views/bo/products/anifood_product.blade.php b/resources/views/bo/products/anifood_product.blade.php index b216b24..cf0fcd5 100644 --- a/resources/views/bo/products/anifood_product.blade.php +++ b/resources/views/bo/products/anifood_product.blade.php @@ -3,3 +3,45 @@ +