CRUD for consumption moment
This commit is contained in:
parent
4da1197ec6
commit
30fb3f7bbc
22 changed files with 778 additions and 34 deletions
175
app/Http/Controllers/Bo/ConsumptionMomentController.php
Normal file
175
app/Http/Controllers/Bo/ConsumptionMomentController.php
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\ConsumptionMoments\StoreConsumptionMomentRequest;
|
||||
use App\Http\Requests\Bo\ConsumptionMoments\UpdateConsumptionMomentRequest;
|
||||
use App\Models\ConsumptionMoment;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ConsumptionMomentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(ConsumptionMoment::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 $consumptionMomentModels */
|
||||
$consumptionMomentModels = ConsumptionMoment::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$consumptionMomentModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
trans('validation.attributes.title'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($consumptionMomentModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$consumptionMomentModels = $this->paginate($consumptionMomentModels);
|
||||
|
||||
return view('bo.pages.consumption_moments.index', compact('consumptionMomentModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*
|
||||
* @param \App\Models\ConsumptionMoment $consumptionMoment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(ConsumptionMoment $consumptionMoment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.consumption_moments.show', ['consumptionMomentModel' => $consumptionMoment]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\ConsumptionMoment $consumptionMoment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(ConsumptionMoment $consumptionMoment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.consumption_moments.create', ['consumptionMomentModel' => $consumptionMoment]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\ConsumptionMoments\StoreConsumptionMomentRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreConsumptionMomentRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$consumptionMoment = new ConsumptionMoment();
|
||||
$consumptionMoment->fill($request->validated());
|
||||
|
||||
if ($consumptionMoment->saveOrFail()) {
|
||||
return redirect()->route('bo.consumption_moments.edit', $consumptionMoment)
|
||||
->with('success', __('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.consumption_moment'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(__('models.classes.consumption_moment'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\ConsumptionMoment $consumptionMoment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(ConsumptionMoment $consumptionMoment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.consumption_moments.edit', ['consumptionMomentModel' => $consumptionMoment]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\ConsumptionMoments\UpdateConsumptionMomentRequest $request
|
||||
* @param \App\Models\ConsumptionMoment $consumptionMoment
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateConsumptionMomentRequest $request,
|
||||
ConsumptionMoment $consumptionMoment
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $consumptionMoment) {
|
||||
$consumptionMoment->fill($request->validated());
|
||||
|
||||
if ($consumptionMoment->saveOrFail()) {
|
||||
return redirect()->route('bo.consumption_moments.edit', $consumptionMoment)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.consumption_moment'))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.consumption_moments.edit', $consumptionMoment)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(__('models.classes.consumption_moment'))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\ConsumptionMoment $consumptionMoment
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(ConsumptionMoment $consumptionMoment): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
/** @var array<string,string> */
|
||||
$previousQueries = [];
|
||||
\parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
|
||||
if ($consumptionMoment->deleteOrFail()) {
|
||||
return redirect()->route('bo.consumption_moments.index', $previousQueries)
|
||||
->with('success', __('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.consumption_moment'))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(__('models.classes.consumption_moment'))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\ConsumptionMoment $consumptionMoment
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(ConsumptionMoment $consumptionMoment): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($consumptionMoment->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ use App\Lib\Helpers\FileStorageHelper;
|
|||
use App\Models\GeneralSetting;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -88,10 +87,9 @@ class GeneralSettingController extends Controller
|
|||
$general_setting->setAttribute(
|
||||
$attribute,
|
||||
$value instanceof \Illuminate\Http\UploadedFile ?
|
||||
FileStorageHelper::storeFile($general_setting, $value, true):
|
||||
FileStorageHelper::storeFile($general_setting, $value, true) :
|
||||
$value
|
||||
)
|
||||
);
|
||||
));
|
||||
} else {
|
||||
$general_setting->fill($request->only('value'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\ConsumptionMoments;
|
||||
|
||||
use App\Models\ConsumptionMoment;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StoreConsumptionMomentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('create', ConsumptionMoment::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|between:3,255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'title' => trans('validation.attributes.title')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\ConsumptionMoments;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class UpdateConsumptionMomentRequest extends StoreConsumptionMomentRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('consumption_moment'));
|
||||
}
|
||||
}
|
||||
27
app/Models/ConsumptionMoment.php
Normal file
27
app/Models/ConsumptionMoment.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $title Title of the consumption moment.
|
||||
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
||||
* @property-read \Illuminate\Support\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class ConsumptionMoment extends Model
|
||||
{
|
||||
use ActivityLog;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
];
|
||||
}
|
||||
75
app/Policies/ConsumptionMomentPolicy.php
Normal file
75
app/Policies/ConsumptionMomentPolicy.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class ConsumptionMomentPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return UserStaticRules::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 a new model.
|
||||
*
|
||||
* @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 duplicate the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function duplicate(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use App\Models\DemarcheSlide;
|
|||
use App\Models\KeyNumber;
|
||||
use App\Models\Profession;
|
||||
use App\Models\BrandAdvantage;
|
||||
use App\Models\ConsumptionMoment;
|
||||
use App\Models\MainSlide;
|
||||
use App\Models\Meat;
|
||||
use App\Models\Range;
|
||||
|
|
@ -62,6 +63,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||
Route::model('meat', Meat::class);
|
||||
Route::model('submeat', Submeat::class);
|
||||
Route::model('approach', Approach::class);
|
||||
Route::model('consumption_moment', ConsumptionMoment::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
20
database/factories/ConsumptionMomentFactory.php
Normal file
20
database/factories/ConsumptionMomentFactory.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ConsumptionMomentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'title' => fake()->words(rand(1, 2), true),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('consumption_moments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->comment('The title of the consumption moment.');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('consumption_moment');
|
||||
}
|
||||
};
|
||||
29
database/seeders/Development/ConsumptionMomentSeeder.php
Normal file
29
database/seeders/Development/ConsumptionMomentSeeder.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Models\ConsumptionMoment;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ConsumptionMomentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = ConsumptionMoment::class;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
ConsumptionMoment::factory(10)->make()->each(function (ConsumptionMoment $consumptionMoment) {
|
||||
$consumptionMoment->saveQuietly();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use Database\Seeders\Development\ApproachSeeder;
|
|||
use Database\Seeders\Development\KeyNumberSeeder;
|
||||
use Database\Seeders\Development\ProfessionSeeder;
|
||||
use Database\Seeders\Development\BrandAdvantageSeeder;
|
||||
use Database\Seeders\Development\ConsumptionMomentSeeder;
|
||||
use Database\Seeders\Development\DemarcheSlideSeeder;
|
||||
use Database\Seeders\Development\MainSlideSeeder;
|
||||
use Database\Seeders\Development\MeatSeeder;
|
||||
|
|
@ -38,6 +39,7 @@ class DevelopmentSeeder extends Seeder
|
|||
MeatSeeder::class,
|
||||
SubmeatSeeder::class,
|
||||
ProductSeeder::class,
|
||||
ConsumptionMomentSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,19 @@
|
|||
|
||||
return [
|
||||
'classes' => [
|
||||
'user' => 'user',
|
||||
'activity_log' => 'activity log|activity logs',
|
||||
'static_page' => 'static page|static pages',
|
||||
'general_setting' => 'configuration',
|
||||
'brand_advantage' => 'brand advantage|brand advantages',
|
||||
'profession' => 'profession',
|
||||
'key_number' => 'key number',
|
||||
'main_slide' => 'main slide',
|
||||
'demarche_slide' => 'demarche slide',
|
||||
'approach' => 'approach|approaches',
|
||||
'hot_news' => 'hot news',
|
||||
'label' => 'label',
|
||||
'demarche' => 'demarche',
|
||||
'user' => 'user',
|
||||
'activity_log' => 'activity log|activity logs',
|
||||
'static_page' => 'static page|static pages',
|
||||
'general_setting' => 'configuration',
|
||||
'brand_advantage' => 'brand advantage|brand advantages',
|
||||
'profession' => 'profession',
|
||||
'key_number' => 'key number',
|
||||
'main_slide' => 'main slide',
|
||||
'demarche_slide' => 'demarche slide',
|
||||
'approach' => 'approach|approaches',
|
||||
'hot_news' => 'hot news',
|
||||
'label' => 'label',
|
||||
'demarche' => 'demarche',
|
||||
'consumption_moment' => 'consumption moment'
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,22 +2,23 @@
|
|||
|
||||
return [
|
||||
'classes' => [
|
||||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'static_page' => 'page statique|pages statiques',
|
||||
'general_setting' => 'configuration',
|
||||
'brand_advantage' => 'avantage de la marque|avantages de la marque',
|
||||
'profession' => 'profession',
|
||||
'key_number' => 'chiffre clé',
|
||||
'main_slide' => 'carrousel (principal)',
|
||||
'demarche_slide' => 'carrousel (démarche)',
|
||||
'hot_news' => 'infos chaudes',
|
||||
'range' => 'gamme',
|
||||
'subrange' => 'sous-gamme',
|
||||
'approach' => 'approche|approches',
|
||||
'meat' => 'viande',
|
||||
'submeat' => 'sous-viande',
|
||||
'label' => 'label',
|
||||
'demarche' => 'démarche',
|
||||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'static_page' => 'page statique|pages statiques',
|
||||
'general_setting' => 'configuration',
|
||||
'brand_advantage' => 'avantage de la marque|avantages de la marque',
|
||||
'profession' => 'profession',
|
||||
'key_number' => 'chiffre clé',
|
||||
'main_slide' => 'carrousel (principal)',
|
||||
'demarche_slide' => 'carrousel (démarche)',
|
||||
'hot_news' => 'infos chaudes',
|
||||
'range' => 'gamme',
|
||||
'subrange' => 'sous-gamme',
|
||||
'approach' => 'approche|approches',
|
||||
'meat' => 'viande',
|
||||
'submeat' => 'sous-viande',
|
||||
'label' => 'label',
|
||||
'demarche' => 'démarche',
|
||||
'consumption_moment' => 'moment de consommation'
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -164,6 +164,15 @@
|
|||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
{{-- CONSUMPTION MOMENTS --}}
|
||||
<a data-bs-toggle="tooltip" href="{{ route('bo.consumption_moments.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.consumption_moment')]) }}" role="button"
|
||||
@class([
|
||||
'btn btn-primary w-100 text-start mt-1',
|
||||
'fw-bold active' => request()->routeIs('bo.consumption_moments.*'),
|
||||
])>
|
||||
<i class="fa-solid fa-user-tie me-1"></i> {{ str(__('models.classes.consumption_moment'))->ucFirst() }}
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
@endauth
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
@extends('bo.layout', ['brParam' => $consumptionMomentModel])
|
||||
|
||||
@section('title', __('Création d\'une :model', ['model' => __('models.classes.consumption_moment')]))
|
||||
@section('description', __('Création d\'une tout nouveau :model', ['model' => __('models.classes.consumption_moment')]))
|
||||
@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.consumption_moments.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.consumption_moment')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $consumptionMomentModel])
|
||||
</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.consumption_moment')]) }}">
|
||||
{{ str(__('crud.actions.save'))->ucfirst() }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.consumption_moments.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('bo.pages.consumption_moments.form')
|
||||
@include('bo.partials.script-button-clone')
|
||||
<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.consumption_moment')]) }}">
|
||||
{{ str(__('crud.actions.save'))->ucfirst() }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
58
resources/views/bo/pages/consumption_moments/edit.blade.php
Normal file
58
resources/views/bo/pages/consumption_moments/edit.blade.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
@extends('bo.layout', ['brParam' => $consumptionMomentModel])
|
||||
|
||||
@section('title', __('Édition d\'une :model', ['model' => __('models.classes.consumption_moment')]))
|
||||
@section('description', __('Édition d\'une :model déjà existant', ['model' => __('models.classes.consumption_moment')]))
|
||||
@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.consumption_moments.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => str(__('models.classes.consumption_moment'))->plural()]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $consumptionMomentModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.consumption_moments.destroy', $consumptionMomentModel) }}" method="POST" novalidate>
|
||||
@can('view', $consumptionMomentModel)
|
||||
<a class="btn btn-warning" data-bs-toggle="tooltip" href="{{ route('bo.consumption_moments.show', $consumptionMomentModel) }}"
|
||||
title="{{ str(__('crud.actions.show'))->ucfirst() }}">
|
||||
<i class="fa-solid fa-eye"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('duplicate', $consumptionMomentModel)
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip" href="{{ route('bo.consumption_moments.duplicate', $consumptionMomentModel) }}"
|
||||
title="{{ str(__('crud.actions.duplicate'))->ucfirst() }}">
|
||||
<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.consumption_moment')]) }}">
|
||||
{{ str(__('crud.actions.save'))->ucfirst() }}
|
||||
</button>
|
||||
@can('delete', $consumptionMomentModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger" data-bs-toggle="tooltip" type="submit" title="{{ str(__('crud.actions.delete'))->ucfirst() }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.consumption_moments.update', $consumptionMomentModel) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.consumption_moments.form')
|
||||
@include('bo.partials.script-button-clone')
|
||||
<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.consumption_moment')]) }}">
|
||||
{{ str(__('crud.actions.save'))->ucfirst() }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
26
resources/views/bo/pages/consumption_moments/form.blade.php
Normal file
26
resources/views/bo/pages/consumption_moments/form.blade.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<div class="row">
|
||||
{{-- TITLE --}}
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'consumptionMomentTitle',
|
||||
'label' => __(':field1 :inter2:model', [
|
||||
'field1' => str(__('validation.custom.attribute_title'))->ucFirst(),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.consumption_moment'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'title',
|
||||
'required' => true,
|
||||
'model' => $consumptionMomentModel ?? null,
|
||||
'helper' => __('crud.minicrud.picture_title_helper'),
|
||||
'placeholder' => __(':field1 :inter2:model', [
|
||||
'field1' => str(__('validation.custom.attribute_title'))->ucFirst(),
|
||||
'inter2' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.consumption_moment'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
<div class="col-12 text-center">
|
||||
<p><b>{{ __('* Champs obligatoires') }}</b></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<table class="table-hover table-fix-action m-0 table">
|
||||
@if (count($consumptionMomentModels) > 0)
|
||||
<thead>
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'title' => str(__('validation.attributes.title'))->ucfirst(),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($consumptionMomentModels as $consumptionMomentModel)
|
||||
<tr class="border-bottom">
|
||||
<td class="text-center align-middle">{{ $consumptionMomentModel->title }}</td>
|
||||
<td class="text-end align-middle">
|
||||
@canAny(['show', 'duplicate', 'update', 'delete'], $consumptionMomentModel)
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.consumption_moments.destroy', $consumptionMomentModel) }}"
|
||||
method="POST" novalidate>
|
||||
@can('view', $consumptionMomentModel)
|
||||
<a class="btn btn-sm btn-warning" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.consumption_moments.show', $consumptionMomentModel) }}"
|
||||
title="{{ str(__('crud.actions.show'))->ucfirst() }}">
|
||||
<i class="fa-solid fa-eye"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('duplicate', $consumptionMomentModel)
|
||||
<a class="btn btn-sm btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.consumption_moments.duplicate', $consumptionMomentModel) }}"
|
||||
title="{{ str(__('crud.actions.duplicate'))->ucfirst() }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('update', $consumptionMomentModel)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.consumption_moments.edit', $consumptionMomentModel) }}"
|
||||
title="{{ str(__('crud.actions.update'))->ucfirst() }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('delete', $consumptionMomentModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ str(__('crud.actions.delete'))->ucfirst() }}">
|
||||
<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">
|
||||
{{ trans_choice('crud.other.no_model_found', 1, ['model' => __('models.classes.consumption_moment')]) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
21
resources/views/bo/pages/consumption_moments/index.blade.php
Normal file
21
resources/views/bo/pages/consumption_moments/index.blade.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title', str(__('models.classes.consumption_moment'))->ucfirst()->plural())
|
||||
@section('description', __('Liste de tous les :model', ['model' => str(__('models.classes.consumption_moment'))->plural()]))
|
||||
|
||||
@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\ConsumptionMoment::class)
|
||||
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" href="{{ route('bo.consumption_moments.create') }}"
|
||||
title="{{ __('crud.helpers.create_model', ['model' => __('models.classes.consumption_moment')]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
@include('bo.pages.consumption_moments.index-list')
|
||||
</div>
|
||||
{{ $consumptionMomentModels->links() }}
|
||||
@endsection
|
||||
73
resources/views/bo/pages/consumption_moments/show.blade.php
Normal file
73
resources/views/bo/pages/consumption_moments/show.blade.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
@extends('bo.layout', ['brParam' => $consumptionMomentModel])
|
||||
|
||||
@section('title', __('Aperçu d\'un :model', ['model' => __('models.classes.consumption_moment')]))
|
||||
@section('description', __('Aperçu d\'un :model déjà existante', ['model' => __('models.classes.consumption_moment')]))
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center border-bottom 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" data-bs-placement="top"
|
||||
href="{{ route('bo.consumption_moments.index', ['sort_col' => 'created_at', 'sort_way' => 'desc']) }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => str(__('models.classes.consumption_moment'))->plural()]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $consumptionMomentModel])
|
||||
</div>
|
||||
@canAny(['duplicate', 'update', 'delete'], $consumptionMomentModel)
|
||||
<form class="btn-group confirmActionTS" data-message="{{ __('crud.sweetalert.data_lost') }}"
|
||||
action="{{ route('bo.consumption_moments.destroy', $consumptionMomentModel) }}" method="POST" novalidate>
|
||||
@can('duplicate', $consumptionMomentModel)
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top"
|
||||
href="{{ route('bo.consumption_moments.duplicate', $consumptionMomentModel) }}"
|
||||
title="{{ __('crud.helpers.duplicate_model', ['model' => __('models.classes.consumption_moment')]) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('update', $consumptionMomentModel)
|
||||
<a class="btn btn-primary" data-bs-toggle="tooltip" data-bs-placement="top"
|
||||
href="{{ route('bo.consumption_moments.edit', $consumptionMomentModel) }}"
|
||||
title="{{ __('crud.helpers.edit_model', ['model' => __('models.classes.consumption_moment')]) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('delete', $consumptionMomentModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger" data-bs-toggle="tooltip" data-bs-placement="top" type="submit"
|
||||
title="{{ __('crud.helpers.delete_model', ['model' => __('models.classes.consumption_moment')]) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
@endcan
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="table-responsive mb-3">
|
||||
<table class="table-hover m-0 table">
|
||||
<tbody>
|
||||
<tr class="border-bottom">
|
||||
<td class="w-50 fw-bold text-center align-middle">{{ str(__('validation.attributes.text'))->ucFirst() }}</td>
|
||||
<td class="w-50 text-center align-middle">
|
||||
{{ $consumptionMomentModel->title }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="border-bottom">
|
||||
<td class="w-50 fw-bold text-center align-middle">{{ str(__('validation.attributes.created_at'))->ucFirst() }}</td>
|
||||
<td class="w-50 text-center align-middle">
|
||||
{{ str($consumptionMomentModel->created_at->isoFormat('LLLL'))->ucFirst() }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="border-bottom">
|
||||
<td class="w-50 fw-bold text-center align-middle">{{ str(__('validation.attributes.updated_at'))->ucFirst() }}</td>
|
||||
<td class="w-50 text-center align-middle">
|
||||
{{ str($consumptionMomentModel->updated_at->isoFormat('LLLL'))->ucFirst() }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -6,6 +6,7 @@ use App\Models\DemarcheSlide;
|
|||
use App\Models\KeyNumber;
|
||||
use App\Models\Profession;
|
||||
use App\Models\BrandAdvantage;
|
||||
use App\Models\ConsumptionMoment;
|
||||
use App\Models\MainSlide;
|
||||
use App\Models\GeneralSetting;
|
||||
use App\Models\Meat;
|
||||
|
|
@ -335,3 +336,28 @@ Breadcrumbs::for('bo.approaches.duplicate', function (Generator $trail, int $app
|
|||
$trail->parent('bo.approaches.index', $approach_type);
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
||||
// * CONSUMPTION_MOMENTS
|
||||
Breadcrumbs::for('bo.consumption_moments.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::ucfirst(trans_choice('models.classes.consumption_moment', \INF)),
|
||||
route('bo.consumption_moments.index')
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.consumption_moments.show', function (Generator $trail, ConsumptionMoment $consumption_moment) {
|
||||
$trail->parent('bo.consumption_moments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.view')), route('bo.consumption_moments.show', $consumption_moment));
|
||||
});
|
||||
|
||||
Breadcrumbs::for('bo.consumption_moments.create', function (Generator $trail) {
|
||||
$trail->parent('bo.consumption_moments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.consumption_moments.create'));
|
||||
});
|
||||
Breadcrumbs::for('bo.consumption_moments.edit', function (Generator $trail, ConsumptionMoment $consumption_moment) {
|
||||
$trail->parent('bo.consumption_moments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.consumption_moments.edit', $consumption_moment));
|
||||
});
|
||||
Breadcrumbs::for('bo.consumption_moments.duplicate', function (Generator $trail) {
|
||||
$trail->parent('bo.consumption_moments.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use App\Http\Controllers\Bo\ActivityLogController;
|
|||
use App\Http\Controllers\Bo\ApproachController;
|
||||
use App\Http\Controllers\Bo\DemarcheSlideController;
|
||||
use App\Http\Controllers\Bo\BrandAdvantageController;
|
||||
use App\Http\Controllers\Bo\ConsumptionMomentController;
|
||||
use App\Http\Controllers\Bo\DashboardController;
|
||||
use App\Http\Controllers\Bo\GeneralSettingController;
|
||||
use App\Http\Controllers\Bo\KeyNumberController;
|
||||
|
|
@ -223,6 +224,12 @@ Route::prefix('bo')
|
|||
Route::get('/approaches/json/paginate', [ApproachController::class, 'jsonPaginate'])
|
||||
->name('approaches.json-paginate');
|
||||
|
||||
// * CONSUMPTION MOMENT.
|
||||
Route::resource('consumption_moments', ConsumptionMomentController::class);
|
||||
Route::get('/consumption_moments/{consumption_moment}/duplicate', [
|
||||
ConsumptionMomentController::class, 'duplicate'
|
||||
])->name('consumption_moments.duplicate');
|
||||
|
||||
Route::middleware('can:isConceptor')->group(function () {
|
||||
// * ACTIVITY LOGS.
|
||||
Route::resource('activity_logs', ActivityLogController::class)->only(['index', 'show']);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue