Types produits
This commit is contained in:
parent
70cb2163df
commit
0822342f64
14 changed files with 223 additions and 50 deletions
|
|
@ -5,6 +5,9 @@ namespace App\Http\Controllers\Bo;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\OldSlug;
|
||||
use App\Models\FoodProduct;
|
||||
use App\Models\ToolProduct;
|
||||
use App\Models\AnifoodProduct;
|
||||
use App\Models\GarmentProduct;
|
||||
use App\Models\Product;
|
||||
use App\Models\Range;
|
||||
use App\Models\Tag;
|
||||
|
|
@ -466,55 +469,42 @@ class ProductsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* helper method to create additionnal product info
|
||||
* foodProduct
|
||||
* helper method to update additionnal product info
|
||||
* toolProduct
|
||||
*/
|
||||
public function storeFoodProduct(Request $request, $product_id)
|
||||
public function saveToolProduct(Request $request, $product_id)
|
||||
{
|
||||
$foodProduct = new FoodProduct();
|
||||
$toolProduct = ToolProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
]);
|
||||
|
||||
$foodProduct->no_art = $request->no_art;
|
||||
$foodProduct->ingredients = $request->ingredients;
|
||||
$foodProduct->preparation = $request->preparation;
|
||||
$foodProduct->servings = $request->servings;
|
||||
$foodProduct->allergens = $request->allergens;
|
||||
$foodProduct->selling_argument = $request->selling_argument;
|
||||
$foodProduct->nv_ref_weight_g = $request->nv_ref_weight_g;
|
||||
$foodProduct->nv_kj = $request->nv_kj;
|
||||
$foodProduct->nv_kcal = $request->nv_kcal;
|
||||
$foodProduct->nv_fat_g = $request->nv_fat_g;
|
||||
$foodProduct->nv_sat_fat_g = $request->nv_sat_fat_g;
|
||||
$foodProduct->nv_carb_g = $request->nv_carb_g;
|
||||
$foodProduct->nv_sugar_g = $request->nv_sugar_g;
|
||||
$foodProduct->nv_fiber_g = $request->nv_fiber_g;
|
||||
$foodProduct->nv_protein_g = $request->nv_protein_g;
|
||||
$foodProduct->nv_salt_g = $request->nv_salt_g;
|
||||
$foodProduct->nv_serving_size_g = $request->nv_serving_size_g;
|
||||
$foodProduct->nv_serving_kj = $request->nv_serving_kj;
|
||||
$foodProduct->nv_serving_kcal = $request->nv_serving_kcal;
|
||||
$foodProduct->nv_serving_fat_g = $request->nv_serving_fat_g;
|
||||
$foodProduct->nv_serving_sat_fat_g = $request->nv_serving_sat_fat_g;
|
||||
$foodProduct->nv_serving_carb_g = $request->nv_serving_carb_g;
|
||||
$foodProduct->nv_serving_sugar_g = $request->nv_serving_sugar_g;
|
||||
$foodProduct->nv_serving_fiber_g = $request->nv_serving_fiber_g;
|
||||
$foodProduct->nv_serving_protein_g = $request->nv_serving_protein_g;
|
||||
$foodProduct->nv_serving_salt_g = $request->nv_serving_salt_g;
|
||||
$foodProduct->nv_daily_energy = $request->nv_daily_energy;
|
||||
$foodProduct->nv_daily_fat = $request->nv_daily_fat;
|
||||
$foodProduct->nv_daily_sat_fat = $request->nv_daily_sat_fat;
|
||||
$foodProduct->nv_daily_carb = $request->nv_daily_carb;
|
||||
$foodProduct->nv_daily_sugar = $request->nv_daily_sugar;
|
||||
$foodProduct->nv_daily_fiber = $request->nv_daily_fiber;
|
||||
$foodProduct->nv_daily_protein = $request->nv_daily_protein;
|
||||
$foodProduct->nv_daily_salt = $request->nv_daily_salt;
|
||||
$foodProduct->nutriscore = $request->nutriscore;
|
||||
$foodProduct->nutriscore_args = $request->nutriscore_args;
|
||||
$toolProduct->save();
|
||||
}
|
||||
|
||||
$foodProduct->product_id = $product_id;
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* anifoodProduct
|
||||
*/
|
||||
public function saveAnifoodProduct(Request $request, $product_id)
|
||||
{
|
||||
$anifoodProduct = AnifoodProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
]);
|
||||
|
||||
$anifoodProduct->save();
|
||||
}
|
||||
|
||||
$foodProduct->save();
|
||||
/**
|
||||
* helper method to update additionnal product info
|
||||
* garmentProduct
|
||||
*/
|
||||
public function saveGarmentProduct(Request $request, $product_id)
|
||||
{
|
||||
$garmentProduct = GarmentProduct::firstOrNew([
|
||||
'product_id' => $product_id,
|
||||
]);
|
||||
|
||||
$garmentProduct->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
10
app/Models/AnifoodProduct.php
Normal file
10
app/Models/AnifoodProduct.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class AnifoodProduct extends ProductType
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
10
app/Models/GarmentProduct.php
Normal file
10
app/Models/GarmentProduct.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class GarmentProduct extends ProductType
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
24
app/Models/ProductType.php
Normal file
24
app/Models/ProductType.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductType extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'product_id',
|
||||
];
|
||||
|
||||
public function product() {
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
}
|
||||
10
app/Models/ToolProduct.php
Normal file
10
app/Models/ToolProduct.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class ToolProduct extends ProductType
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
10
composer.lock
generated
10
composer.lock
generated
|
|
@ -1189,16 +1189,16 @@
|
|||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v8.37.0",
|
||||
"version": "v8.40.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "cf4082973abc796ec285190f0603380021f6d26f"
|
||||
"reference": "a654897ad7f97aea9d7ef292803939798c4a02a4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/cf4082973abc796ec285190f0603380021f6d26f",
|
||||
"reference": "cf4082973abc796ec285190f0603380021f6d26f",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/a654897ad7f97aea9d7ef292803939798c4a02a4",
|
||||
"reference": "a654897ad7f97aea9d7ef292803939798c4a02a4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1353,7 +1353,7 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2021-04-13T13:49:49+00:00"
|
||||
"time": "2021-04-28T14:38:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/tinker",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateToolProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* Table de caractéristiques spécifiques pour les outils
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tool_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
//liaison à la table produits
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
|
||||
//longeur, largeur, puissance, usage, conseils?
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('tool_products');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAnifoodProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* Table de caractéristiques spécifiques pour les aliments pour animaux
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('anifood_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
//liaison à la table produits
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
|
||||
//compostions, portions, ?
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('anifood_products');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateGarmentProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* Table de caractéristiques spécifiques pour les vêtements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('garment_products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
//liaison à la table produits
|
||||
$table->foreignId('product_id')->constrained('products');
|
||||
|
||||
//taille, couleur, matière ?
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('garment_products');
|
||||
}
|
||||
}
|
||||
5
resources/views/bo/products/anifood_product.blade.php
Normal file
5
resources/views/bo/products/anifood_product.blade.php
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h2><small class="text-muted">Aliment pour animaux</small></h2>
|
||||
<input type="hidden" id="product_type" name="product_type" value="anifoodProduct">
|
||||
</div>
|
||||
<!--adding fields (anifood_products)-->
|
||||
|
|
@ -178,7 +178,7 @@
|
|||
Publié ?
|
||||
</label>
|
||||
</div>
|
||||
@if(!empty($product_type))
|
||||
@if(!empty($product->product_type))
|
||||
@include('bo.products.' . Str::snake($product->product_type))
|
||||
@endif
|
||||
</form>
|
||||
|
|
|
|||
5
resources/views/bo/products/garment_product.blade.php
Normal file
5
resources/views/bo/products/garment_product.blade.php
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h2><small class="text-muted">Vêtement</small></h2>
|
||||
<input type="hidden" id="product_type" name="product_type" value="garmentProduct">
|
||||
</div>
|
||||
<!--adding fields (garment_products)-->
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
@foreach (Config::get('theme.enum_product_types') as $productType=>$label)
|
||||
<a class="dropdown-item" href="{{route('bo.products.create', $productType)}}">{{ __($label)}}</a>
|
||||
<a class="dropdown-item" href="{{route('bo.products.create', $productType)}}">{{ __($label)}}</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
5
resources/views/bo/products/tool_product.blade.php
Normal file
5
resources/views/bo/products/tool_product.blade.php
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h2><small class="text-muted">Outil</small></h2>
|
||||
<input type="hidden" id="product_type" name="product_type" value="toolProduct">
|
||||
</div>
|
||||
<!--adding fields (tool_products)-->
|
||||
Loading…
Add table
Reference in a new issue