Added Product CRUD
This commit is contained in:
parent
3e64820fb8
commit
d61f05640d
22 changed files with 1533 additions and 31 deletions
181
app/Http/Controllers/Bo/ProductController.php
Normal file
181
app/Http/Controllers/Bo/ProductController.php
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Products\StoreProductRequest;
|
||||
use App\Http\Requests\Bo\Products\UpdateProductRequest;
|
||||
use App\Models\Product;
|
||||
use App\Models\Range;
|
||||
use App\Traits\Controllers\ChangesModelOrder;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
use ChangesModelOrder;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $productModels */
|
||||
$productModels = Product::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$productModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
'subtitle',
|
||||
'description',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title')),
|
||||
trans('validation.custom.subtitle'),
|
||||
trans('validation.custom.description'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($productModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$productModels = $this->paginate($productModels);
|
||||
|
||||
return view('bo.pages.products.index', compact('productModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Product $product
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(Product $product): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$rangeModels = Range::all();
|
||||
return view('bo.pages.products.create', [
|
||||
'productModel' => $product,
|
||||
'rangeModels' => $rangeModels,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Products\StoreProductRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreProductRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$product = new Product();
|
||||
$product->fill($request->validated());
|
||||
|
||||
if ($product->saveOrFail()) {
|
||||
return redirect()->route('bo.products.edit', $product)
|
||||
->with('success', __('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.product'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.product'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\Product $product
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Product $product): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$rangeModels = Range::all();
|
||||
return view('bo.pages.products.edit', [
|
||||
'productModel' => $product,
|
||||
'rangeModels' => $rangeModels,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Products\UpdateProductRequest $request
|
||||
* @param \App\Models\Product $product
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateProductRequest $request, Product $product): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $product) {
|
||||
$product->fill($request->validated());
|
||||
|
||||
if ($product->saveOrFail()) {
|
||||
return redirect()->route('bo.products.edit', $product)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.product'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.products.edit', $product)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.product'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Product $product
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(Product $product): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($product) {
|
||||
$product->commitments()->detach();
|
||||
if ($product->deleteOrFail()) {
|
||||
return redirect()->route('bo.products.index')
|
||||
->with('success', __('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.product'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.product'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Product $product
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(Product $product): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($product->replicate());
|
||||
}
|
||||
}
|
||||
156
app/Http/Requests/Bo/Products/StoreProductRequest.php
Normal file
156
app/Http/Requests/Bo/Products/StoreProductRequest.php
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Products;
|
||||
|
||||
use App\Enums\Products\CookingModeEnum;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreProductRequest extends FormRequest
|
||||
{
|
||||
use HasPicture;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false
|
||||
]);
|
||||
$this->mergePicture('picture_thumbnail');
|
||||
$this->mergePicture('picture_ambiance');
|
||||
$this->mergePicture('picture_packshot');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'seo_title' => 'required|between:45,70',
|
||||
'seo_description' => 'required|between:50,160',
|
||||
'title' => 'required|string|between:3,100',
|
||||
'subtitle' => 'required|string|between:3,255',
|
||||
'picture_thumbnail_alt' => 'required|string|between:3,255',
|
||||
'picture_thumbnail_title' => 'required|string|between:3,255',
|
||||
'picture_ambiance_alt' => 'required|string|between:3,255',
|
||||
'picture_ambiance_title' => 'required|string|between:3,255',
|
||||
'picture_packshot_alt' => 'required|string|between:3,255',
|
||||
'picture_packshot_title' => 'required|string|between:3,255',
|
||||
'description' => 'required|string|min:15',
|
||||
'cooking_mode' => ['required', new Enum(CookingModeEnum::class)],
|
||||
'cooking_advice' => 'required|string|min:15',
|
||||
'ingredients' => 'required|string|min:15',
|
||||
'nutritionnal_values' => 'required|array',
|
||||
'nutritionnal_values.*' => 'required|numeric|min:0',
|
||||
'range_id' => 'required|exists:ranges,id',
|
||||
'published' => 'required|boolean',
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture_thumbnail', 332, 252, 332, 252, false),
|
||||
$this->pictureRules('picture_ambiance', 774, 515, 774, 515, false),
|
||||
$this->pictureRules('picture_packshot', 327, 252, 327, 252, false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override validated() function from FormRequest.
|
||||
*
|
||||
* @param array|integer|string|null $key
|
||||
* @param mixed $default
|
||||
* @return array
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed
|
||||
*/
|
||||
public function validated($key = null, mixed $default = null): array
|
||||
{
|
||||
// phpcs:enable
|
||||
$nutritionnal_values = json_encode([
|
||||
"energyKj" => [
|
||||
"label" => "Energie en Kj",
|
||||
"value" => $this->nutritionnal_values['energy_kj'],
|
||||
],
|
||||
"energyKcal" => [
|
||||
"label" => "Energie en kcal",
|
||||
"value" => $this->nutritionnal_values['energy_kcal'],
|
||||
],
|
||||
"fat" => [
|
||||
"label" => "Matières grasses",
|
||||
"value" => $this->nutritionnal_values['fat'],
|
||||
],
|
||||
"saturated-fat" => [
|
||||
"label" => "dont acides gras saturés",
|
||||
"value" => $this->nutritionnal_values['saturated_fat'],
|
||||
],
|
||||
"carbohydrate" => [
|
||||
"label" => "Glucides",
|
||||
"value" => $this->nutritionnal_values['carbohydrate'],
|
||||
],
|
||||
"sugar" => [
|
||||
"label" => "dont sucres",
|
||||
"value" => $this->nutritionnal_values['sugar'],
|
||||
],
|
||||
"proteins" => [
|
||||
"label" => "Protéines",
|
||||
"value" => $this->nutritionnal_values['proteins'],
|
||||
],
|
||||
"salt" => [
|
||||
"label" => "Sel",
|
||||
"value" => $this->nutritionnal_values['salt'],
|
||||
]
|
||||
]);
|
||||
|
||||
return array_merge(
|
||||
parent::validated(),
|
||||
[
|
||||
'nutritionnal_values' => $nutritionnal_values
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'seo_title' => trans('validation.custom.seo_title'),
|
||||
'seo_description' => trans('validation.custom.seo_description'),
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'subtitle' => trans('validation.custom.subtitle'),
|
||||
'description' => trans('validation.custom.description'),
|
||||
'picture_thumbnail_alt' => trans('validation.custom.picture_thumbnail_alt'),
|
||||
'picture_thumbnail_title' => trans('validation.custom.picture_thumbnail_title'),
|
||||
'picture_ambiance_alt' => trans('validation.custom.picture_ambiance_alt'),
|
||||
'picture_ambiance_title' => trans('validation.custom.picture_ambiance_title'),
|
||||
'picture_packshot_alt' => trans('validation.custom.picture_packshot_alt'),
|
||||
'picture_packshot_title' => trans('validation.custom.picture_packshot_title'),
|
||||
'cooking_mode' => trans('validation.custom.cooking_mode'),
|
||||
'cooking_advice' => trans('validation.custom.cooking_advice'),
|
||||
'ingredients' => trans('validation.custom.ingredients'),
|
||||
'nutritionnal_values' => trans('validation.custom.nutritionnal_values'),
|
||||
'range_id' => trans('models.classes.range'),
|
||||
'published' => trans('validation.custom.activated'),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/Bo/Products/UpdateProductRequest.php
Normal file
7
app/Http/Requests/Bo/Products/UpdateProductRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Products;
|
||||
|
||||
class UpdateProductRequest extends StoreProductRequest
|
||||
{
|
||||
}
|
||||
120
app/Policies/ProductPolicy.php
Normal file
120
app/Policies/ProductPolicy.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class ProductPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function restore(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function forceDelete(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can duplicate the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function duplicate(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can publish/unpublish the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function changePublished(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can change the order of the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function changeOrder(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use App\Models\Explorerpage;
|
|||
use App\Models\Homepage;
|
||||
use App\Models\Range;
|
||||
use App\Models\News;
|
||||
use App\Models\Product;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Models\Stamp;
|
||||
use App\Models\User;
|
||||
|
|
@ -55,8 +56,8 @@ class RouteServiceProvider extends ServiceProvider
|
|||
Route::model('seasonal_section', SeasonalSection::class);
|
||||
Route::model('homepage', Homepage::class);
|
||||
Route::model('stamp', Stamp::class);
|
||||
Route::model('news', News::class);
|
||||
Route::model('explorerpage', Explorerpage::class);
|
||||
Route::model('product', Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,41 @@ class ProductFactory extends Factory
|
|||
{
|
||||
$title = fake()->sentence();
|
||||
|
||||
$nutritionnal_values = [
|
||||
'energyKj' => [
|
||||
'label' => 'Energie en Kj',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'energyKcal' => [
|
||||
'label' => 'Energie en kcal',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'fat' => [
|
||||
'label' => 'Matières grasses',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'saturated-fat' => [
|
||||
'label' => 'dont acides gras saturés',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'carbohydrate' => [
|
||||
'label' => 'Glucides',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'sugar' => [
|
||||
'label' => 'dont sucres',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'proteins' => [
|
||||
'label' => 'Protéines',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
'salt' => [
|
||||
'label' => 'Sel',
|
||||
'value' => fake()->randomFloat(2, 0, 70)
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'seo_title' => fake()->word(),
|
||||
'seo_description' => fake()->text(160),
|
||||
|
|
@ -34,15 +69,7 @@ class ProductFactory extends Factory
|
|||
'cooking_mode' => \collect(CookingModeEnum::cases())->random(),
|
||||
'cooking_advice' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'ingredients' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'nutritionnal_values' => json_encode([
|
||||
'Energie en Kj' => fake()->randomFloat(2),
|
||||
'Energie en kcal' => fake()->randomFloat(2),
|
||||
'Matières grasses' => fake()->randomFloat(2),
|
||||
'dont acides gras saturés' => fake()->randomFloat(2),
|
||||
'Glucides' => fake()->randomFloat(2),
|
||||
'Protéines' => fake()->randomFloat(2),
|
||||
'Sel' => fake()->randomFloat(2),
|
||||
]),
|
||||
'nutritionnal_values' => json_encode($nutritionnal_values),
|
||||
'published' => fake()->boolean(75),
|
||||
'range_id' => Range::all()->random()->id,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -17,17 +17,18 @@ class ProductSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
FileStorageHelper::removeModelFiles(new Product());
|
||||
Product::factory(25)->create([
|
||||
'picture_thumbnail' => FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
Product::factory(25)->make()->each(function (Product $product) {
|
||||
$product->picture_thumbnail = FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/products/default-picture-332x252.png'
|
||||
))),
|
||||
'picture_ambiance' => FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
)));
|
||||
$product->picture_ambiance = FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/products/default-picture-774x515.png'
|
||||
))),
|
||||
'picture_packshot' => FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
)));
|
||||
$product->picture_packshot = FileStorageHelper::storeFile(new Product(), new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/products/default-picture-327x252.png'
|
||||
)))
|
||||
]);
|
||||
)));
|
||||
$product->save();
|
||||
});
|
||||
|
||||
$commitments = Commitment::query()->get();
|
||||
Product::query()->each(function (Product $product) use ($commitments) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ return [
|
|||
'visibility_with_dates' => 'This field will only have an effect if no date is entered.',
|
||||
'publish_at' => 'The :model will be published from that date.',
|
||||
'unpublish_at' => 'The :model will be unpublished from that date.',
|
||||
'nutritionnal_values' => 'Values must be given in grams, except for energy in kJ and kcal.',
|
||||
],
|
||||
|
||||
'libs' => [
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ return [
|
|||
'seasonal_section' => 'seasonal section|seasonal sections',
|
||||
'news' => 'news',
|
||||
'stamp' => 'stamp',
|
||||
'commitment' => 'commitment',
|
||||
'range' => 'range',
|
||||
'homepage' => 'home page',
|
||||
'explorerpage' => 'explorer page',
|
||||
'homepage' => 'home page',
|
||||
'explorerpage' => 'explorer page',
|
||||
'commitment' => 'commitment',
|
||||
'product' => 'product',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -252,5 +252,10 @@ return [
|
|||
'category' => 'category',
|
||||
'publish_at' => 'publication date',
|
||||
'unpublish_at' => 'end of publication date',
|
||||
'picture_ambiance' => 'ambiance picture',
|
||||
'picture_packshot' => 'packshot picture',
|
||||
'cooking_advice' => 'cooking advice',
|
||||
'ingredients' => 'ingredients',
|
||||
'nutritionnal_values' => 'nutritionnal values',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ return [
|
|||
'visibility_with_dates' => 'Ce champ n\'aura d\'effet que si aucune date n\'est renseignée.',
|
||||
'publish_at' => 'Le :model sera publié à partir de cette date.',
|
||||
'unpublish_at' => 'Le :model sera dépublié à partir de cette date.',
|
||||
'nutritionnal_values' => 'Les valeurs doivent être renseignées en grammes,
|
||||
exceptés pour l\'énergie en kJ et en kcal.',
|
||||
],
|
||||
|
||||
'libs' => [
|
||||
|
|
@ -68,7 +70,7 @@ return [
|
|||
'picture_title_label' => 'Attribut du titre de l\'image',
|
||||
'picture_alt_helper' => 'Doit décrire votre image pour les moteurs de recherche et les aveugles (5 à 6 mots)',
|
||||
'picture_alt_label' => 'Attribut Alt de l\'image',
|
||||
'text_warning' => 'Relisez votre contenu avant de le publier',
|
||||
'text_warning' => 'Relisez votre contenu avant de le publier.',
|
||||
],
|
||||
|
||||
'pagination' => [
|
||||
|
|
|
|||
|
|
@ -12,5 +12,6 @@ return [
|
|||
'news' => 'actualité',
|
||||
'stamp' => 'tampon',
|
||||
'explorerpage' => 'page explorateur',
|
||||
'product' => 'produit',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -254,5 +254,10 @@ return [
|
|||
'category' => 'catégorie',
|
||||
'publish_at' => 'date de publication',
|
||||
'unpublish_at' => 'date de fin de publication',
|
||||
'picture_ambiance' => 'image d\'ambiance',
|
||||
'picture_packshot' => 'image du packshot',
|
||||
'cooking_advice' => 'conseil de réchauffage',
|
||||
'ingredients' => 'ingrédients',
|
||||
'nutritionnal_values' => 'valeurs nutritionnelles',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -24,14 +24,6 @@
|
|||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\Range::class)
|
||||
<li>
|
||||
<a class="nav-link @if (request()->routeIs('bo.ranges.*')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.ranges.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.range'))]) }}">
|
||||
{{ Str::of(__('models.classes.range'))->plural()->ucfirst() }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\News::class)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.news.*')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.news.index') }}"
|
||||
|
|
@ -75,6 +67,34 @@
|
|||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
<a class="nav-link @if (request()->routeIs('bo.products.*') || request()->routeIs('bo.ranges.*')) active @endif dropdown-toggle" data-bs-toggle="dropdown" type="button"
|
||||
aria-expanded="false">
|
||||
{{ __('Produits') }}
|
||||
</a>
|
||||
<ol class="dropdown-menu">
|
||||
@can('viewAny', \App\Models\Product::class)
|
||||
<li>
|
||||
<a class="dropdown-item @if (request()->routeIs('bo.products.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.products.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.product'))]) }}">
|
||||
{{ Str::of(__('models.classes.product'))->plural()->ucfirst() }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\Range::class)
|
||||
<li>
|
||||
<a class="dropdown-item @if (request()->routeIs('bo.ranges.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.ranges.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.range'))]) }}">
|
||||
{{ Str::of(__('models.classes.range'))->plural()->ucfirst() }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
</ol>
|
||||
</div>
|
||||
</li>
|
||||
@canAny(['isConceptor', 'viewAny'], \App\Models\User::class)
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
|
|
|
|||
36
resources/views/bo/pages/products/create.blade.php
Normal file
36
resources/views/bo/pages/products/create.blade.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
@extends('bo.layout', ['brParam' => $productModel])
|
||||
|
||||
@section('title', __('Création d\'un :model', ['model' => __('models.classes.product')]))
|
||||
@section('description', __('Création d\'un tout nouveau :model', ['model' => __('models.classes.product')]))
|
||||
@section('breadcrumb',
|
||||
request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-toggle="tooltip" href="{{ route('bo.products.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.product')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $productModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.product')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.products.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('bo.pages.products.form')
|
||||
<div class="row mt-3">
|
||||
<div class="col text-center">
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.product')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
52
resources/views/bo/pages/products/edit.blade.php
Normal file
52
resources/views/bo/pages/products/edit.blade.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
@extends('bo.layout', ['brParam' => $productModel])
|
||||
|
||||
@section('title', __('Édition d\'un :model', ['model' => __('models.classes.product')]))
|
||||
@section('description', __('Édition d\'un :model déjà existant', ['model' => __('models.classes.product')]))
|
||||
@section('breadcrumb',
|
||||
request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-toggle="tooltip" href="{{ route('bo.products.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.product'))]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $productModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.products.destroy', $productModel) }}" method="POST" novalidate>
|
||||
@can('duplicate', $productModel)
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip" href="{{ route('bo.products.duplicate', ['product' => $productModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.product')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
@can('delete', $productModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger" data-bs-toggle="tooltip" type="submit" title="{{ Str::ucfirst(__('crud.actions.delete')) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.products.update', $productModel) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.products.form')
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.product')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
541
resources/views/bo/pages/products/form.blade.php
Normal file
541
resources/views/bo/pages/products/form.blade.php
Normal file
|
|
@ -0,0 +1,541 @@
|
|||
<div class="row">
|
||||
{{-- SEO --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.seo')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- SEO_TITLE --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productSeoTitle',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_title')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'seo_title',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => sprintf(
|
||||
'%s %s',
|
||||
__('crud.helpers.seo_title'),
|
||||
__('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.custom.seo_title'),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'min' => 45,
|
||||
'max' => 70,
|
||||
])),
|
||||
'placeholder' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_title')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- SEO_DESCRIPTION --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar-multiline', [
|
||||
'id' => 'productSeoDescription',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_description')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'seo_description',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => sprintf(
|
||||
'%s %s',
|
||||
__('crud.helpers.seo_description'),
|
||||
__('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.custom.seo_description'),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'min' => 50,
|
||||
'max' => 160,
|
||||
])),
|
||||
'placeholder' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_description')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.title')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productTitle',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.attributes.title')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'title',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.attributes.title'),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'min' => 3,
|
||||
'max' => 100,
|
||||
]),
|
||||
'placeholder' => __('Un titre clair et concis'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- SUBTITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.subtitle')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productSubtitle',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.subtitle')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'subtitle',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.subtitle')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'min' => 3,
|
||||
'max' => 255,
|
||||
]),
|
||||
'placeholder' => __('Un sous-titre clair et concis'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- RANGE_ID --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('models.classes.range')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.bigint-foreign-id', [
|
||||
'id' => 'productRange',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('models.classes.range')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'name' => 'range_id',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'associatedModels' => $rangeModels ?? null,
|
||||
'foreignLabel' => 'title',
|
||||
'helper' => __('crud.minicrud.select', [
|
||||
'entity' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PUBLISHED --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ __('crud.minicrud.visibility_label') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.tinyint-boolean', [
|
||||
'id' => 'productStatus',
|
||||
'name' => 'published',
|
||||
'model' => $productModel ?? null,
|
||||
'label' => __('crud.minicrud.visibility_label'),
|
||||
'helper' => __('crud.minicrud.visibility_helper'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- DESCRIPTION --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.description')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.text-html', [
|
||||
'id' => 'productDescription',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.description')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'name' => 'description',
|
||||
'model' => $productModel ?? null,
|
||||
'required' => true,
|
||||
'helper' => __('crud.minicrud.text_warning'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PICTURE_THUMBNAIL --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.picture_thumbnail')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- PICTURE_THUMBNAIL_ALT --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productPictureThumbnailAlt',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.female'),
|
||||
'field2' => __('validation.custom.picture_thumbnail'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_thumbnail_alt',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_alt_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.female'),
|
||||
'field2' => __('validation.custom.picture_thumbnail'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_THUMBNAIL_TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productPictureThumbnailTitle',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.female'),
|
||||
'field2' => __('validation.custom.picture_thumbnail'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_thumbnail_title',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_title_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.female'),
|
||||
'field2' => __('validation.custom.picture_thumbnail'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_THUMBNAIL --}}
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar-picture', [
|
||||
'id' => 'productPictureThumbnail',
|
||||
'name' => 'picture_thumbnail',
|
||||
'width' => 332,
|
||||
'height' => 252,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.dimensions_must_be', [
|
||||
'widthpx' => '332px',
|
||||
'heightpx' => '252px',
|
||||
]),
|
||||
'required' => true,
|
||||
'preview' => true,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PICTURE_AMBIANCE --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.picture_ambiance')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- PICTURE_AMBIANCE_ALT --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productPictureAmbianceAlt',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_ambiance'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_ambiance_alt',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_alt_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_ambiance'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_AMBIANCE_TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productPictureAmbianceTitle',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_ambiance'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_ambiance_title',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_title_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_ambiance'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_AMBIANCE --}}
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar-picture', [
|
||||
'id' => 'productPictureAmbiance',
|
||||
'name' => 'picture_ambiance',
|
||||
'width' => 774,
|
||||
'height' => 515,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.dimensions_must_be', [
|
||||
'widthpx' => '774px',
|
||||
'heightpx' => '515px',
|
||||
]),
|
||||
'required' => true,
|
||||
'preview' => true,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PICTURE_PACKSHOT --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.picture_packshot')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- PICTURE_PACKSHOT_ALT --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productPicturePackshotAlt',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_packshot'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_packshot_alt',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_alt_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_packshot'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_PACKSHOT_TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'productPicturePackshotTitle',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_packshot'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_packshot_title',
|
||||
'required' => true,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_title_helper'),
|
||||
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.custom.picture_packshot'),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_PACKSHOT --}}
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar-picture', [
|
||||
'id' => 'productPicturePackshot',
|
||||
'name' => 'picture_packshot',
|
||||
'width' => 327,
|
||||
'height' => 252,
|
||||
'model' => $productModel ?? null,
|
||||
'helper' => __('crud.minicrud.dimensions_must_be', [
|
||||
'widthpx' => '327px',
|
||||
'heightpx' => '252px',
|
||||
]),
|
||||
'required' => true,
|
||||
'preview' => true,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- COOKING --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ __('Préparation') }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- COOKING_MODE --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.tinyint-enum', [
|
||||
'id' => 'productCookingMode',
|
||||
'label' => __('Associer un mode de cuisson'),
|
||||
'name' => 'cooking_mode',
|
||||
'model' => $productModel ?? null,
|
||||
'required' => true,
|
||||
'associatedModels' => \App\Enums\Products\CookingModeEnum::toArray(),
|
||||
'helper' => __('Sélectionnez un mode de cuisson dans la liste déroulante.'),
|
||||
])
|
||||
</div>
|
||||
{{-- COOKING_ADVICE --}}
|
||||
<div class="col-12 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.text-html', [
|
||||
'id' => 'productCookingAdvice',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.cooking_advice')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'name' => 'cooking_advice',
|
||||
'model' => $productModel ?? null,
|
||||
'required' => true,
|
||||
'helper' => __('crud.minicrud.text_warning') .
|
||||
__('validation.gt.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.custom.cooking_advice'),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'value' => 15,
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- INGREDIENTS --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.ingredients')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.text-html', [
|
||||
'id' => 'productIngredients',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.ingredients')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'name' => 'ingredients',
|
||||
'model' => $productModel ?? null,
|
||||
'required' => true,
|
||||
'helper' => __('crud.minicrud.text_warning') .
|
||||
__('validation.gt.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.custom.ingredients'),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'value' => 15,
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- NUTRITIONNAL_VALUES --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.nutritionnal_values')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.json-nutritionnal-values', [
|
||||
'id' => 'productNutritionnalValues',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.nutritionnal_values')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.product'),
|
||||
]),
|
||||
'name' => 'nutritionnal_values',
|
||||
'model' => $productModel ?? null,
|
||||
'required' => true,
|
||||
'helper' => __('crud.helpers.nutritionnal_values')
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<p><b>{{ __('* Champs obligatoires') }}</b></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
submitClone = document.getElementById('formSubmitClone');
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
83
resources/views/bo/pages/products/index-list.blade.php
Normal file
83
resources/views/bo/pages/products/index-list.blade.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<table class="table-hover table-fix-action m-0 table">
|
||||
@if (count($productModels) > 0)
|
||||
<thead>
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'title' => Str::ucfirst(__('validation.attributes.title')),
|
||||
'subtitle' => Str::ucfirst(__('validation.custom.subtitle')),
|
||||
'picture_packshot' => Str::ucfirst(__('validation.custom.picture_packshot')),
|
||||
'order' => Str::ucfirst(__('validation.custom.order')),
|
||||
'published' => Str::ucfirst(__('validation.custom.activated')),
|
||||
'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($productModels as $productModel)
|
||||
<tr class="border-bottom list-item">
|
||||
<td class="text-center align-middle">{{ $productModel->title }}</td>
|
||||
<td class="text-center align-middle">{{ $productModel->subtitle }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<img height="50px" src="/{{ $productModel->picture_packshot }}">
|
||||
</td>
|
||||
@php
|
||||
$routeName = request()
|
||||
->route()
|
||||
->getName();
|
||||
@endphp
|
||||
@if (empty(request()->search) && Session::get("$routeName.sort_col") === 'order')
|
||||
@include('bo.modules.change-model-order', [
|
||||
'routeName' => 'products',
|
||||
'model' => $productModel,
|
||||
'models' => $productModels,
|
||||
])
|
||||
@endif
|
||||
@include('bo.modules.change-published-status', [
|
||||
'routeName' => 'products',
|
||||
'model' => $productModel,
|
||||
])
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-secondary">{{ $productModel->updated_at->isoFormat('LLLL') }}</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
@canAny(['delete', 'duplicate', 'update'], $productModel)
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.products.destroy', $productModel) }}" method="POST"
|
||||
novalidate>
|
||||
@can('duplicate', $productModel)
|
||||
<a class="btn btn-sm btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.products.duplicate', ['product' => $productModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('update', $productModel)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.products.edit', ['product' => $productModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.update')) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('delete', $productModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ Str::ucfirst(__('crud.actions.delete')) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
@else
|
||||
<span class="text-danger" data-bs-toggle="tooltip" title="{{ __('list.right') }}">
|
||||
<i class="fa-solid fa-ban"></i>
|
||||
</span>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@else
|
||||
<tr>
|
||||
<td class="border-0">{{ __('crud.other.no_model_found', ['model' => __('models.classes.product')]) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
21
resources/views/bo/pages/products/index.blade.php
Normal file
21
resources/views/bo/pages/products/index.blade.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title', Str::ucfirst(__('models.classes.product')))
|
||||
@section('description', __('Liste de tous les :model', ['model' => Str::plural(__('models.classes.product'))]))
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
@can('create', \App\Models\Product::class)
|
||||
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" href="{{ route('bo.products.create') }}"
|
||||
title="{{ __('crud.helpers.create_model', ['model' => __('models.classes.product')]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
@include('bo.pages.products.index-list')
|
||||
</div>
|
||||
{{ $productModels->links() }}
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
{{--
|
||||
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
|
||||
|
||||
$id || The id of the input tag. || string || REQUIRED ||
|
||||
$name || The name of the input tag. || string || REQUIRED ||
|
||||
$helper || The helper of the input. || string || REQUIRED ||
|
||||
$required || Is the field required ? || boolean || OPTIONNAL || false
|
||||
$model || The model we're creating/editing || Model class || OPTIONNAL || null
|
||||
--}}
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
{{ __('Label') }}
|
||||
</th>
|
||||
<th>
|
||||
{{ __('Valeur') }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{-- ENERGIE EN KCAL --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}EnergyKcal" class="col-form-label">
|
||||
{{ __('Energie en kcal') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[energy_kcal]"
|
||||
type="number"
|
||||
value="{{ old('energy-kcal', json_decode($model->{$name}, true)['energyKcal']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}EnergyKcal"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('204') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- ENERGIE EN KJ --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}EnergyKj" class="col-form-label">
|
||||
{{ __('Energie en kJ') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[energy_kj]"
|
||||
type="number"
|
||||
value="{{ old('energy-kj', json_decode($model->{$name}, true)['energyKj']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}EnergyKj"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('846') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- MATIERES GRASSES --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}Fat" class="col-form-label">
|
||||
{{ __('Matières grasses') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[fat]"
|
||||
type="number"
|
||||
value="{{ old('fat', json_decode($model->{$name}, true)['fat']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}Fat"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('17') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- ACIDES GRAS SATURES --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}SaturatedFat" class="col-form-label">
|
||||
{{ __('dont acides gras saturés') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[saturated_fat]"
|
||||
type="number"
|
||||
value="{{ old('saturated-fat', json_decode($model->{$name}, true)['saturated-fat']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}SaturatedFat"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('2.2') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- GLUCIDES --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}Carbohydrate" class="col-form-label">
|
||||
{{ __('Glucides') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[carbohydrate]"
|
||||
type="number"
|
||||
value="{{ old('carbohydrate', json_decode($model->{$name}, true)['carbohydrate']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}Carbohydrate"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('3.5') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- DONT SUCRES --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}Sugar" class="col-form-label">
|
||||
{{ __('dont sucres') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[sugar]"
|
||||
type="number"
|
||||
value="{{ old('sugar', json_decode($model->{$name}, true)['sugar']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}Sugar"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('0.9') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- PROTEINES --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}Proteins" class="col-form-label">
|
||||
{{ __('Protéines') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[proteins]"
|
||||
type="number"
|
||||
value="{{ old('proteins', json_decode($model->{$name}, true)['proteins']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}Proteins"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('9.0') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- SEL --}}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{{ $id }}Salt" class="col-form-label">
|
||||
{{ __('Sel') }} {{ $required ?? false ? '*' : '' }}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="nutritionnal_values[salt]"
|
||||
type="number"
|
||||
value="{{ old('salt', json_decode($model->{$name}, true)['salt']['value'] ?? 0) }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif"
|
||||
id="{{ $id }}Salt"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ __('1.27') }}"
|
||||
step="0.01"
|
||||
min="0"
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@include('modules.input-error', [
|
||||
'inputName' => $name,
|
||||
'helperId' => $id.'Help',
|
||||
'helper' => $helper
|
||||
])
|
||||
|
|
@ -6,6 +6,7 @@ use App\Models\Explorerpage;
|
|||
use App\Models\Homepage;
|
||||
use App\Models\Range;
|
||||
use App\Models\News;
|
||||
use App\Models\Product;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Models\Stamp;
|
||||
use App\Models\StaticPage;
|
||||
|
|
@ -181,3 +182,23 @@ Breadcrumbs::for('bo.stamps.duplicate', function (Generator $trail) {
|
|||
$trail->parent('bo.stamps.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
||||
// * PRODUCTS
|
||||
Breadcrumbs::for('bo.products.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::of(trans('models.classes.product'))->plural()->ucfirst(),
|
||||
route('bo.products.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.products.create', function (Generator $trail) {
|
||||
$trail->parent('bo.products.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.products.create'));
|
||||
});
|
||||
Breadcrumbs::for('bo.products.edit', function (Generator $trail, Product $product) {
|
||||
$trail->parent('bo.products.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.products.edit', $product));
|
||||
});
|
||||
Breadcrumbs::for('bo.products.duplicate', function (Generator $trail) {
|
||||
$trail->parent('bo.products.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Bo\DashboardController;
|
|||
use App\Http\Controllers\Bo\ExplorerpageController;
|
||||
use App\Http\Controllers\Bo\HomepageController;
|
||||
use App\Http\Controllers\Bo\NewsController;
|
||||
use App\Http\Controllers\Bo\ProductController;
|
||||
use App\Http\Controllers\Bo\StaticPageController;
|
||||
use App\Http\Controllers\Bo\RangeController;
|
||||
use App\Http\Controllers\Bo\SeasonalSectionController;
|
||||
|
|
@ -131,6 +132,20 @@ Route::prefix('bo')
|
|||
Route::resource('explorerpages', ExplorerpageController::class)->only(['index', 'edit', 'update'])
|
||||
->withoutMiddleware('htmlsanitize');
|
||||
|
||||
// * PRODUCTS
|
||||
Route::resource('products', ProductController::class)->except('show')
|
||||
->withoutMiddleware('htmlsanitize')
|
||||
->middleware('htmlsanitize:description,cooking_advice,ingredients');
|
||||
Route::patch('/products/{product}/change-published', [
|
||||
ProductController::class, 'changePublished'
|
||||
])->name('products.change-published');
|
||||
Route::patch('/products/{product}/change-order/{direction}', [
|
||||
ProductController::class, 'changeOrder'
|
||||
])->where('direction', 'up|down')->name('products.change-order');
|
||||
Route::get('/products/{product}/duplicate', [
|
||||
ProductController::class, 'duplicate'
|
||||
])->name('products.duplicate');
|
||||
|
||||
Route::middleware('can:isConceptor')->group(function () {
|
||||
// * ACTIVITY LOGS.
|
||||
Route::resource('activity_logs', ActivityLogsController::class)->only(['index', 'show']);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue