Merge branch 'crud-seasonalsections' into 2.0.0
This commit is contained in:
commit
0d7bdd5901
18 changed files with 830 additions and 16 deletions
167
app/Http/Controllers/Bo/SeasonalSectionController.php
Normal file
167
app/Http/Controllers/Bo/SeasonalSectionController.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\SeasonalSections\StoreSeasonalSectionRequest;
|
||||
use App\Http\Requests\Bo\SeasonalSections\UpdateSeasonalSectionRequest;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SeasonalSectionController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(SeasonalSection::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 $seasonalSectionModels */
|
||||
$seasonalSectionModels = SeasonalSection::query();
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$seasonalSectionModels,
|
||||
$search,
|
||||
null,
|
||||
'title',
|
||||
'text',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
Str::ucfirst(trans('validation.attributes.title')),
|
||||
trans('validation.attributes.text'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($seasonalSectionModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$seasonalSectionModels = $this->paginate($seasonalSectionModels);
|
||||
|
||||
return view('bo.pages.seasonal_sections.index', compact('seasonalSectionModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\SeasonalSection $seasonalSection
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function create(SeasonalSection $seasonalSection): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.seasonal_sections.create', ['seasonalSectionModel' => $seasonalSection]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\SeasonalSections\StoreSeasonalSectionRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreSeasonalSectionRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$seasonalSection = new SeasonalSection();
|
||||
$seasonalSection->fill($request->validated());
|
||||
|
||||
if ($seasonalSection->saveOrFail()) {
|
||||
return redirect()->route('bo.seasonalsections.edit', $seasonalSection)
|
||||
->with('success', __('crud.messages.has_been_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_created', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\SeasonalSection $seasonalSection
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(SeasonalSection $seasonalSection): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('bo.pages.seasonal_sections.edit', ['seasonalSectionModel' => $seasonalSection]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\SeasonalSections\UpdateSeasonalSectionRequest $request
|
||||
* @param \App\Models\SeasonalSection $seasonalSection
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(
|
||||
UpdateSeasonalSectionRequest $request,
|
||||
SeasonalSection $seasonalSection
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $seasonalSection) {
|
||||
$seasonalSection->fill($request->validated());
|
||||
|
||||
if ($seasonalSection->saveOrFail()) {
|
||||
return redirect()->route('bo.seasonalsections.edit', $seasonalSection)
|
||||
->with('success', __('crud.messages.has_been_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->route('bo.seasonalsections.edit', $seasonalSection)
|
||||
->with('error', __('crud.messages.cannot_be_updated', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\SeasonalSection $seasonalSection
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(SeasonalSection $seasonalSection): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
if ($seasonalSection->deleteOrFail()) {
|
||||
return redirect()->route('bo.seasonalsections.index')
|
||||
->with('success', __('crud.messages.has_been_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||
]));
|
||||
}
|
||||
return redirect()->back()
|
||||
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\SeasonalSection $seasonalSection
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function duplicate(SeasonalSection $seasonalSection): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return $this->create($seasonalSection->replicate());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\SeasonalSections;
|
||||
|
||||
use App\Enums\SeasonalSections\BackgroundEnum;
|
||||
use App\Traits\Requests\HasPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreSeasonalSectionRequest 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'title' => 'required|string|between:3,100',
|
||||
'text' => 'required|string|min:15',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
'background' => ['required', new Enum(BackgroundEnum::class)],
|
||||
'published' => 'required|boolean',
|
||||
'publish_at' => 'nullable|date',
|
||||
'unpublish_at' => 'nullable|date|after:publish_at',
|
||||
|
||||
];
|
||||
return \array_merge(
|
||||
$rules,
|
||||
$this->pictureRules('picture', 362, 542, 362, 542, false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'title' => trans('validation.attributes.title'),
|
||||
'text' => trans('validation.attributes.content'),
|
||||
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||
'picture_title' => trans('validation.custom.picture_title'),
|
||||
'background' => trans('validation.custom.background'),
|
||||
'published' => trans('validation.custom.activated'),
|
||||
'publish_at' => trans('validation.custom.publish_at'),
|
||||
'unpublish_at' => trans('validation.custom.unpublish_at'),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\SeasonalSections;
|
||||
|
||||
class UpdateSeasonalSectionRequest extends StoreSeasonalSectionRequest
|
||||
{
|
||||
}
|
||||
109
app/Policies/SeasonalSectionPolicy.php
Normal file
109
app/Policies/SeasonalSectionPolicy.php
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class SeasonalSectionPolicy
|
||||
{
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use App\Models\Range;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Models\User;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
|
@ -44,6 +45,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||
|
||||
Route::model('user', User::class);
|
||||
Route::model('range', Range::class);
|
||||
Route::model('seasonal_section', SeasonalSection::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class SeasonalSectionFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'title' => fake()->sentence(),
|
||||
'text' => fake()->text(),
|
||||
'text' => \clean(\fake()->randomHtml(6, 7)),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
'picture_title' => fake()->sentence(),
|
||||
'published' => false,
|
||||
|
|
|
|||
|
|
@ -20,15 +20,21 @@ class SeasonalSectionSeeder extends Seeder
|
|||
$publish_at = now()->subDays(rand(1, 10));
|
||||
$unpublish_at = $publish_at->copy()->addDays(rand(10, 20));
|
||||
foreach (BackgroundEnum::cases() as $i => $background) {
|
||||
SeasonalSection::factory(1)->create([
|
||||
'background' => $background,
|
||||
'published' => $i === array_key_first(BackgroundEnum::cases()) ? true : false,
|
||||
'publish_at' => $publish_at->subMonths(),
|
||||
'unpublish_at' => $unpublish_at->subMonths(),
|
||||
'picture' => FileStorageHelper::storeFile(new SeasonalSection(), new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/seasonalsections/default-picture-362x542.png')
|
||||
)),
|
||||
]);
|
||||
SeasonalSection::factory(1)->make()->each(
|
||||
function (SeasonalSection $seasonalSection) use ($background, $i, $publish_at, $unpublish_at) {
|
||||
$seasonalSection->background = $background;
|
||||
$seasonalSection->published = $i === array_key_first(BackgroundEnum::cases()) ? true : false;
|
||||
$seasonalSection->publish_at = $publish_at->subMonths();
|
||||
$seasonalSection->unpublish_at = $unpublish_at->subMonths();
|
||||
$seasonalSection->picture = FileStorageHelper::storeFile(
|
||||
new SeasonalSection(),
|
||||
new \SplFileInfo(
|
||||
\resource_path('../database/factories/assets/seasonalsections/default-picture-362x542.png')
|
||||
)
|
||||
);
|
||||
$seasonalSection->save();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,6 +237,6 @@ return [
|
|||
'attribute_title' => 'title attribute',
|
||||
'picture_productsheet' => 'productsheet picture',
|
||||
'picture_thumbnail' => 'thumbnail',
|
||||
|
||||
'background' => 'background',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
return [
|
||||
'classes' => [
|
||||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'static_page' => 'page statique|pages statiques',
|
||||
'range' => 'gamme',
|
||||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'static_page' => 'page statique|pages statiques',
|
||||
'range' => 'gamme',
|
||||
'seasonal_section' => 'section saisonnière|sections saisonnières',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -237,6 +237,6 @@ return [
|
|||
'attribute_title' => 'attribut title',
|
||||
'picture_productsheet' => 'image de la fiche produit',
|
||||
'picture_thumbnail' => 'vignette',
|
||||
|
||||
'background' => 'fond',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -24,6 +24,15 @@
|
|||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('viewAny', \App\Models\SeasonalSection::class)
|
||||
<li>
|
||||
<a class="nav-link @if (request()->routeIs('bo.seasonalsections.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.seasonalsections.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::title(trans_choice('models.classes.seasonal_section', '*'))]) }}">
|
||||
{{ Str::title(trans_choice('models.classes.seasonal_section', '*')) }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@canAny(['isConceptor', 'viewAny'], \App\Models\User::class)
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
|
|
|
|||
36
resources/views/bo/pages/seasonal_sections/create.blade.php
Normal file
36
resources/views/bo/pages/seasonal_sections/create.blade.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
@extends('bo.layout', ['brParam' => $seasonalSectionModel])
|
||||
|
||||
@section('title', __('Création d\'une :model', ['model' => trans_choice('models.classes.seasonal_section', 1)]))
|
||||
@section('description', __('Création d\'une toute nouvelle :model', ['model' => trans_choice('models.classes.seasonal_section', 1)]))
|
||||
@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.seasonalsections.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => trans_choice('models.classes.seasonal_section', '*')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $seasonalSectionModel])
|
||||
</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' => trans_choice('models.classes.seasonal_section', 1)]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('bo.seasonalsections.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('bo.pages.seasonal_sections.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' => trans_choice('models.classes.seasonal_section', 1)]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
52
resources/views/bo/pages/seasonal_sections/edit.blade.php
Normal file
52
resources/views/bo/pages/seasonal_sections/edit.blade.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
@extends('bo.layout', ['brParam' => $seasonalSectionModel])
|
||||
|
||||
@section('title', __('Édition d\'un :model', ['model' => __('models.classes.seasonal_section')]))
|
||||
@section('description', __('Édition d\'un :model déjà existant', ['model' => __('models.classes.seasonal_section')]))
|
||||
@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.seasonalsections.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.seasonal_section'))]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $seasonalSectionModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.seasonalsections.destroy', $seasonalSectionModel) }}" method="POST" novalidate>
|
||||
@can('duplicate', $seasonalSectionModel)
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip" href="{{ route('bo.seasonalsections.duplicate', ['seasonal_section' => $seasonalSectionModel]) }}"
|
||||
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.seasonal_section')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
@can('delete', $seasonalSectionModel)
|
||||
@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.seasonalsections.update', $seasonalSectionModel) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.seasonal_sections.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.seasonal_section')]) }}">
|
||||
{{ Str::ucfirst(__('crud.actions.save')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
220
resources/views/bo/pages/seasonal_sections/form.blade.php
Normal file
220
resources/views/bo/pages/seasonal_sections/form.blade.php
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
<div class="row">
|
||||
{{-- 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' => 'seasonalSectionTitle',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.attributes.title')),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'title',
|
||||
'required' => true,
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.attributes.title'),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
'min' => 3,
|
||||
'max' => 100,
|
||||
]),
|
||||
'placeholder' => __('Un titre clair et concis'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- BACKGROUND --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.background')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.tinyint-enum', [
|
||||
'id' => 'seasonalSectionBackground',
|
||||
'label' => __('Associer un fond'),
|
||||
'name' => 'background',
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'required' => true,
|
||||
'associatedModels' => \App\Enums\SeasonalSections\BackgroundEnum::toArray(),
|
||||
'helper' => __('Sélectionnez un fond dans la liste déroulante.'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- TEXT --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.content')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.text-html', [
|
||||
'id' => 'seasonalSectionText',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.attributes.text')),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
'name' => 'text',
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'required' => true,
|
||||
'helper' => __('crud.minicrud.text_warning'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PICTURE --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.image')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- PICTURE_ALT --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'seasonalSectionPictureAlt',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_alt')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.attributes.image'),
|
||||
'inter2' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_alt',
|
||||
'required' => true,
|
||||
'model' => $seasonalSectionModel ?? 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.attributes.image'),
|
||||
'inter2' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE_TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'seasonalSectionPictureTitle',
|
||||
'label' => __(':field1 :inter1:field2 :inter2:model', [
|
||||
'field1' => Str::ucfirst(__('validation.custom.attribute_title')),
|
||||
'inter1' => __('validation.custom.of_the.vowel'),
|
||||
'field2' => __('validation.attributes.image'),
|
||||
'inter2' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_title',
|
||||
'required' => true,
|
||||
'model' => $seasonalSectionModel ?? 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.attributes.image'),
|
||||
'inter2' => __('validation.custom.of_the.female'),
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- PICTURE --}}
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.varchar-picture', [
|
||||
'id' => 'seasonalSectionPicture',
|
||||
'name' => 'picture',
|
||||
'width' => 362,
|
||||
'height' => 542,
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'helper' => __('crud.minicrud.dimensions_must_be', [
|
||||
'widthpx' => '362px',
|
||||
'heightpx' => '542px',
|
||||
]),
|
||||
'required' => true,
|
||||
'preview' => true,
|
||||
])
|
||||
</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' => 'seasonalSectionPublished',
|
||||
'name' => 'published',
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'label' => __('crud.minicrud.visibility_label'),
|
||||
'helper' => sprintf('%s %s', __('crud.minicrud.visibility_helper'), __('crud.helpers.visibility_with_dates')),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- PUBLICATION --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ __('Publication') }}</legend>
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
@include('bo.partials.inputs.timestamp-datetime', [
|
||||
'label' => Str::ucfirst(__('validation.custom.publish_at')) . __(' (Europe/Paris)'),
|
||||
'id' => 'seasonalSectionPublishedAt',
|
||||
'name' => 'publish_at',
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'helper' => __('crud.helpers.publish_at', [
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
@include('bo.partials.inputs.timestamp-datetime', [
|
||||
'label' => Str::ucfirst(__('validation.custom.unpublish_at')) . __(' (Europe/Paris)'),
|
||||
'id' => 'seasonalSectionUnPublishedAt',
|
||||
'name' => 'unpublish_at',
|
||||
'model' => $seasonalSectionModel ?? null,
|
||||
'helper' => __('crud.helpers.unpublish_at', [
|
||||
'model' => trans_choice('models.classes.seasonal_section', 1),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</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
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<table class="table-hover table-fix-action m-0 table">
|
||||
@if (count($seasonalSectionModels) > 0)
|
||||
<thead>
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'title' => Str::ucfirst(__('validation.attributes.title')),
|
||||
'background' => Str::ucfirst(__('validation.custom.background')),
|
||||
'picture' => Str::ucfirst(__('validation.attributes.image')),
|
||||
'published' => Str::ucfirst(__('validation.custom.activated')),
|
||||
'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($seasonalSectionModels as $seasonalSectionModel)
|
||||
<tr class="border-bottom list-item">
|
||||
<td class="text-center align-middle">{{ $seasonalSectionModel->title }}</td>
|
||||
<td class="text-center align-middle">{{ $seasonalSectionModel->background->label() }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<img height="50px" src="/{{ $seasonalSectionModel->picture }}">
|
||||
</td>
|
||||
@include('bo.modules.change-published-status', [
|
||||
'routeName' => 'seasonalsections',
|
||||
'model' => $seasonalSectionModel,
|
||||
])
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-secondary">{{ $seasonalSectionModel->updated_at->isoFormat('LLLL') }}</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
@canAny(['delete', 'duplicate', 'update'], $seasonalSectionModel)
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.seasonalsections.destroy', $seasonalSectionModel) }}" method="POST"
|
||||
novalidate>
|
||||
@can('duplicate', $seasonalSectionModel)
|
||||
<a class="btn btn-sm btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.seasonalsections.duplicate', ['seasonal_section' => $seasonalSectionModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('update', $seasonalSectionModel)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.seasonalsections.edit', ['seasonal_section' => $seasonalSectionModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.update')) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('delete', $seasonalSectionModel)
|
||||
@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.seasonal_section')]) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
21
resources/views/bo/pages/seasonal_sections/index.blade.php
Normal file
21
resources/views/bo/pages/seasonal_sections/index.blade.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title', Str::ucfirst(trans_choice('models.classes.seasonal_section', '*')))
|
||||
@section('description', __('Liste de tous les :model', ['model' => trans_choice('models.classes.seasonal_section', '*')]))
|
||||
|
||||
@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\Range::class)
|
||||
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" href="{{ route('bo.seasonalsections.create') }}"
|
||||
title="{{ __('crud.helpers.create_model', ['model' => trans_choice('models.classes.seasonal_section', 1)]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
@include('bo.pages.seasonal_sections.index-list')
|
||||
</div>
|
||||
{{ $seasonalSectionModels->links() }}
|
||||
@endsection
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\Range;
|
||||
use App\Models\SeasonalSection;
|
||||
use App\Models\StaticPage;
|
||||
use App\Models\User;
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
|
|
@ -71,3 +72,23 @@ Breadcrumbs::for('bo.ranges.duplicate', function (Generator $trail) {
|
|||
$trail->parent('bo.ranges.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
||||
// * SEASONAL SECTIONS
|
||||
Breadcrumbs::for('bo.seasonalsections.index', function (Generator $trail) {
|
||||
$trail->push(
|
||||
Str::ucfirst(trans_choice('models.classes.seasonal_section', '*')),
|
||||
route('bo.seasonalsections.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.seasonalsections.create', function (Generator $trail) {
|
||||
$trail->parent('bo.seasonalsections.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.seasonalsections.create'));
|
||||
});
|
||||
Breadcrumbs::for('bo.seasonalsections.edit', function (Generator $trail, SeasonalSection $seasonal_section) {
|
||||
$trail->parent('bo.seasonalsections.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.seasonalsections.edit', $seasonal_section));
|
||||
});
|
||||
Breadcrumbs::for('bo.seasonalsections.duplicate', function (Generator $trail) {
|
||||
$trail->parent('bo.seasonalsections.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use App\Http\Controllers\Bo\ActivityLogsController;
|
|||
use App\Http\Controllers\Bo\DashboardController;
|
||||
use App\Http\Controllers\Bo\StaticPageController;
|
||||
use App\Http\Controllers\Bo\RangeController;
|
||||
use App\Http\Controllers\Bo\SeasonalSectionController;
|
||||
use App\Http\Controllers\Bo\UsersController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
|
@ -62,6 +63,18 @@ Route::prefix('bo')
|
|||
RangeController::class, 'duplicate'
|
||||
])->name('ranges.duplicate');
|
||||
|
||||
// * SEASONAL SECTIONS.
|
||||
Route::resource('seasonalsections', SeasonalSectionController::class)->except('show')
|
||||
->parameters(['seasonalsections' => 'seasonal_section'])
|
||||
->withoutMiddleware('htmlsanitize')
|
||||
->middleware('htmlsanitize:text');
|
||||
Route::patch('/seasonalsections/{seasonal_section}/change-published', [
|
||||
SeasonalSectionController::class, 'changePublished'
|
||||
])->name('seasonalsections.change-published');
|
||||
Route::get('/seasonalsections/{seasonal_section}/duplicate', [
|
||||
SeasonalSectionController::class, 'duplicate'
|
||||
])->name('seasonalsections.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