diff --git a/app/Http/Controllers/Bo/HomepageController.php b/app/Http/Controllers/Bo/HomepageController.php new file mode 100644 index 0000000..31964aa --- /dev/null +++ b/app/Http/Controllers/Bo/HomepageController.php @@ -0,0 +1,93 @@ +authorizeResource(Homepage::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 $homepageModels */ + $homepageModels = Homepage::query(); + + /** @var string $search Search field */ + $search = $request->search; + if ($search) { + $this->searchQuery( + $homepageModels, + $search, + null, + 'title_part1', + 'title_part2', + 'title_part3' + ); + } + $searchFields = \implode(', ', [ + Str::ucfirst(trans('validation.attributes.title')) + ]); + + /** Sort columns with a query */ + $this->sortQuery($homepageModels); + + /** Custom pagination */ + $homepageModels = $this->paginate($homepageModels); + + return view('bo.pages.homepages.index', compact('homepageModels', 'search', 'searchFields')); + } + + /** + * Show the form for editing the specified resource. + * + * @param App\Models\Homepage $homepage + * @return \Illuminate\Contracts\View\View + */ + public function edit(Homepage $homepage): \Illuminate\Contracts\View\View + { + return view('bo.pages.homepages.edit', ['homepageModel' => $homepage]); + } + + /** + * Update the specified resource in storage. + * + * @param \App\Http\Requests\Bo\Homepages\UpdateHomepageRequest $request + * @param \App\Models\Homepage $homepage + * @return \Illuminate\Http\RedirectResponse + */ + public function update(UpdateHomepageRequest $request, Homepage $homepage): \Illuminate\Http\RedirectResponse + { + return DB::transaction(function () use ($request, $homepage) { + $homepage->fill($request->validated()); + + if ($homepage->saveOrFail()) { + return redirect()->route('bo.homepages.edit', $homepage) + ->with('success', __('crud.messages.has_been_updated', [ + 'model' => Str::ucfirst(__('models.classes.homepage')) + ])); + } + return redirect()->route('bo.homepages.edit', $homepage) + ->with('error', __('crud.messages.cannot_be_updated', [ + 'model' => Str::ucfirst(__('models.classes.homepage')) + ])); + }); + } +} diff --git a/app/Http/Requests/Bo/Homepage/StoreHomepageRequest.php b/app/Http/Requests/Bo/Homepage/StoreHomepageRequest.php new file mode 100644 index 0000000..f6b0d87 --- /dev/null +++ b/app/Http/Requests/Bo/Homepage/StoreHomepageRequest.php @@ -0,0 +1,53 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation() + { + $this->mergePicture('picture'); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + $rules = [ + 'title_part1' => 'required|string|between:3,255', + 'title_part2' => 'required|string|between:3,255', + 'title_part3' => 'required|string|between:3,255', + 'picture_alt' => 'required|string|between:3,255', + 'picture_title' => 'required|string|between:3,255', + 'presentation_title' => 'required|string|between:3,255', + 'presentation_content' => 'required|string', + ]; + return \array_merge( + $rules, + $this->pictureRules('picture', 640, 390, 640, 390, false), + ); + } +} diff --git a/app/Http/Requests/Bo/Homepage/UpdateHomepageRequest.php b/app/Http/Requests/Bo/Homepage/UpdateHomepageRequest.php new file mode 100644 index 0000000..a102925 --- /dev/null +++ b/app/Http/Requests/Bo/Homepage/UpdateHomepageRequest.php @@ -0,0 +1,18 @@ + */ protected $fillable = [ - 'title_part_1', - 'title_part_2', - 'title_part_3', + 'title_part1', + 'title_part2', + 'title_part3', 'picture', 'picture_alt', 'picture_title', diff --git a/app/Policies/HomepagePolicy.php b/app/Policies/HomepagePolicy.php new file mode 100644 index 0000000..27ab78c --- /dev/null +++ b/app/Policies/HomepagePolicy.php @@ -0,0 +1,43 @@ + 'Must give a precise description of the page, which is recommended for optimum positioning in search engines ( tag).', 'seo_description' => 'Must give a precise description of the page content (<meta> description tag).', + 'required_fields' => 'Required fields', '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.', diff --git a/resources/lang/en/models.php b/resources/lang/en/models.php index 141dedf..4e1852e 100644 --- a/resources/lang/en/models.php +++ b/resources/lang/en/models.php @@ -10,5 +10,7 @@ return [ 'news' => 'news', 'stamp' => 'stamp', 'commitment' => 'commitment', + 'range' => 'range', + 'homepage' => 'homepage' ] ]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index b91de8b..df49a2e 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -241,6 +241,11 @@ return [ 'publish_at' => 'publication date', 'unpublish_at' => 'end of publication date', 'background' => 'background', + 'picture' => 'picture', + 'presentation_title' => 'presentation title', + 'title_part1' => 'title part one', + 'title_part2' => 'title part two', + 'title_part3' => 'title part three', 'category' => 'category', 'publish_at' => 'publication date', 'unpublish_at' => 'end of publication date', diff --git a/resources/lang/fr/crud.php b/resources/lang/fr/crud.php index 8efb22f..7117ede 100644 --- a/resources/lang/fr/crud.php +++ b/resources/lang/fr/crud.php @@ -28,6 +28,7 @@ return [ 'seo_title' => 'Doit décrire précisément la page, recommandation pour un positionnement optimal dans les moteurs de recherche (balise <title>).', 'seo_description' => 'Doit décrire précisément le contenu de la page (balise <meta> description).', + 'required_fields' => 'Champs obligatoires', '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.', diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index 29cabe6..3dc2ec3 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -8,6 +8,7 @@ return [ 'commitment' => 'engagement', 'range' => 'gamme', 'seasonal_section' => 'section saisonnière|sections saisonnières', + 'homepage' => 'page d\'accueil', 'news' => 'actualité', 'stamp' => 'tampon', ] diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index fd090d5..b86718c 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -243,6 +243,11 @@ return [ 'publish_at' => 'date de publication', 'unpublish_at' => 'date de fin de publication', 'background' => 'fond', + 'picture' => 'image', + 'presentation_title' => 'titre de présentation', + 'title_part1' => 'première partie du titre', + 'title_part2' => 'seconde partie du titre', + 'title_part3' => 'dernière partie du titre', 'category' => 'catégorie', 'publish_at' => 'date de publication', 'unpublish_at' => 'date de fin de publication', diff --git a/resources/views/bo/layouts/nav-list.blade.php b/resources/views/bo/layouts/nav-list.blade.php index 54d66d8..8a40904 100644 --- a/resources/views/bo/layouts/nav-list.blade.php +++ b/resources/views/bo/layouts/nav-list.blade.php @@ -34,8 +34,7 @@ @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') }}" + <a class="nav-link @if (request()->routeIs('bo.news.*')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.news.index') }}" title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.news'))->plural()->title()]) }}"> {{ Str::of(__('models.classes.news'))->plural()->title() }} </a> @@ -50,10 +49,18 @@ </a> </li> @endcan + @can('viewAny', \App\Models\Homepage::class) + <li> + <a class="nav-link @if (request()->routeIs('bo.homepages.*')) active @endif" data-bs-toggle="tooltip" + href="{{ route('bo.homepages.index') }}" + title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.commitment'))->plural()]) }}"> + {{ Str::of(__('models.classes.homepage'))->plural()->ucfirst() }} + </a> + </li> + @endcan @can('viewAny', \App\Models\Stamp::class) <li> - <a class="nav-link @if (request()->routeIs('bo.stamps.*')) active @endif" data-bs-toggle="tooltip" - href="{{ route('bo.stamps.index') }}" + <a class="nav-link @if (request()->routeIs('bo.stamps.*')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.stamps.index') }}" title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.stamp'))->plural()->title()]) }}"> {{ Str::of(__('models.classes.stamp'))->plural()->title() }} </a> @@ -61,8 +68,7 @@ @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') }}" + <a class="nav-link @if (request()->routeIs('bo.news.*')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.news.index') }}" title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.news'))->plural()->title()]) }}"> {{ Str::of(__('models.classes.news'))->plural()->title() }} </a> diff --git a/resources/views/bo/pages/homepages/edit.blade.php b/resources/views/bo/pages/homepages/edit.blade.php new file mode 100644 index 0000000..f7bc9a0 --- /dev/null +++ b/resources/views/bo/pages/homepages/edit.blade.php @@ -0,0 +1,39 @@ +@extends('bo.layout', ['brParam' => $homepageModel]) + +@section('title', trans_choice('crud.meta.title.edit', 0, ['model' => __('models.classes.homepage')])) +@section('description', trans_choice('crud.meta.description.edit', 0, ['model' => __('models.classes.homepage')])) +@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.homepages.index') }}" + title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.homepage'))]) }}"> + <i class="fa-solid fa-arrow-left"></i> + </a> + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $homepageModel]) + </div> + <div class="mb-md-0 mb-2"> + <form class="btn-group confirmDeleteTS" action="{{ route('bo.homepages.edit', $homepageModel) }}" method="POST" novalidate> + <button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit" + title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.homepage')]) }}"> + {{ Str::ucfirst(__('crud.actions.save')) }} + </button> + </form> + </div> + </div> + <form action="{{ route('bo.homepages.update', $homepageModel) }}" method="POST" enctype="multipart/form-data"> + @csrf + @method('PUT') + @include('bo.pages.homepages.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.homepage')]) }}"> + {{ Str::ucfirst(__('crud.actions.save')) }} + </button> + </div> + </div> + </form> +@endsection diff --git a/resources/views/bo/pages/homepages/form.blade.php b/resources/views/bo/pages/homepages/form.blade.php new file mode 100644 index 0000000..54b145b --- /dev/null +++ b/resources/views/bo/pages/homepages/form.blade.php @@ -0,0 +1,245 @@ +<div class="row"> + {{-- TITLE PART 1 --}} + <div class="col-12 col-md-6 mb-3"> + <fieldset class="h-100 border p-3"> + <legend>{{ Str::ucfirst(__('validation.custom.title_part1')) }}</legend> + <div class="row"> + <div class="col-12"> + @include('bo.partials.inputs.varchar', [ + 'id' => 'homepageTitlePart1', + 'label' => __(':field :inter:model', [ + 'field' => Str::ucfirst(__('validation.custom.title_part1')), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'hasWordCounter' => true, + 'name' => 'title_part1', + 'required' => true, + 'model' => $homepageModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field :inter:model', [ + 'field' => __('validation.custom.title_part1'), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'min' => 3, + 'max' => 255, + ]), + 'placeholder' => __('crud.placeholders.beautiful', ['field' => __('validation.attributes.title')]), + ]) + </div> + </div> + </fieldset> + </div> + {{-- TITLE PART 2 --}} + <div class="col-12 col-md-6 mb-3"> + <fieldset class="h-100 border p-3"> + <legend>{{ Str::ucfirst(__('validation.custom.title_part2')) }}2</legend> + <div class="row"> + <div class="col-12"> + @include('bo.partials.inputs.varchar', [ + 'id' => 'homepageTitlePart2', + 'label' => __(':field :inter:model', [ + 'field' => Str::ucfirst(__('validation.custom.title_part2')), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'hasWordCounter' => true, + 'name' => 'title_part2', + 'required' => true, + 'model' => $homepageModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field :inter:model', [ + 'field' => __('validation.custom.title_part2'), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'min' => 3, + 'max' => 255, + ]), + 'placeholder' => __('crud.placeholders.beautiful', ['field' => __('validation.attributes.title')]), + ]) + </div> + </div> + </fieldset> + </div> + {{-- TITLE PART 3 --}} + <div class="col-12 col-md-6 mb-3"> + <fieldset class="h-100 border p-3"> + <legend>{{ Str::ucfirst(__('validation.custom.title_part3')) }}3</legend> + <div class="row"> + <div class="col-12"> + @include('bo.partials.inputs.varchar', [ + 'id' => 'homepageTitlePart3', + 'label' => __(':field :inter:model', [ + 'field' => Str::ucfirst(__('validation.custom.title_part3')), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'hasWordCounter' => true, + 'name' => 'title_part3', + 'required' => true, + 'model' => $homepageModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field :inter:model', [ + 'field' => __('validation.custom.title_part3'), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'min' => 3, + 'max' => 255, + ]), + 'placeholder' => __('crud.placeholders.beautiful', ['field' => __('validation.attributes.title')]), + ]) + </div> + </div> + </fieldset> + </div> + {{-- PICTURE --}} + <div class="col-12 pb-3"> + <fieldset class="h-100 border p-3"> + <legend>{{ Str::ucfirst(__('validation.custom.picture')) }}</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' => 'homepagePictureAlt', + 'label' => __(':field1 :inter1:field2 :inter2:model', [ + 'field1' => Str::ucfirst(__('validation.custom.attribute_alt')), + 'inter1' => __('validation.custom.of_the.vowel'), + 'field2' => __('validation.custom.picture'), + 'inter2' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_alt', + 'required' => true, + 'model' => $homepageModel ?? 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'), + 'inter2' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + ]) + </div> + {{-- PICTURE_TITLE --}} + <div class="col-12 col-md-6 mb-3"> + @include('bo.partials.inputs.varchar', [ + 'id' => 'homepagePictureTitle', + 'label' => __(':field1 :inter1:field2 :inter2:model', [ + 'field1' => Str::ucfirst(__('validation.custom.attribute_title')), + 'inter1' => __('validation.custom.of_the.vowel'), + 'field2' => __('validation.custom.picture'), + 'inter2' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_title', + 'required' => true, + 'model' => $homepageModel ?? 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'), + 'inter2' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + ]) + </div> + {{-- PICTURE --}} + <div class="col-12"> + @include('bo.partials.inputs.varchar-picture', [ + 'id' => 'homepagePicture', + 'name' => 'picture', + 'width' => 640, + 'height' => 390, + 'model' => $homepageModel ?? null, + 'helper' => __('crud.minicrud.dimensions_must_be', [ + 'widthpx' => '640px', + 'heightpx' => '390px', + ]), + 'required' => true, + 'preview' => true, + ]) + </div> + </div> + </fieldset> + </div> + {{-- PRESENTATION TITLE --}} + <div class="col-12 col-md-6 mb-3"> + <fieldset class="h-100 border p-3"> + <legend>{{ Str::ucfirst(__('validation.custom.presentation_title')) }}</legend> + <div class="row"> + <div class="col-12"> + @include('bo.partials.inputs.varchar', [ + 'id' => 'homepagePresentationTitle', + 'label' => __(':field :inter:model', [ + 'field' => Str::ucfirst(__('validation.custom.presentation_title')), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'hasWordCounter' => true, + 'name' => 'presentation_title', + 'required' => true, + 'model' => $homepageModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field :inter:model', [ + 'field' => __('validation.custom.presentation_title'), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'min' => 3, + 'max' => 255, + ]), + 'placeholder' => __('crud.placeholders.beautiful', ['field' => __('validation.attributes.title')]), + ]) + </div> + </div> + </fieldset> + </div> + {{-- CONTENT --}} + <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' => 'homepagePresentationContent', + 'label' => __(':field :inter:model', [ + 'field' => Str::ucfirst(__('validation.attributes.content')), + 'inter' => __('validation.custom.of_the.female'), + 'model' => __('models.classes.homepage'), + ]), + 'name' => 'presentation_content', + 'model' => $homepageModel ?? null, + 'required' => true, + 'helper' => __('crud.minicrud.text_warning'), + ]) + </div> + </div> + </fieldset> + </div> + <div class="row"> + <div class="col text-center"> + <p><b>* {{ __('crud.helpers.required_fields') }}</b></p> + </div> + </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 diff --git a/resources/views/bo/pages/homepages/index-list.blade.php b/resources/views/bo/pages/homepages/index-list.blade.php new file mode 100644 index 0000000..41304dd --- /dev/null +++ b/resources/views/bo/pages/homepages/index-list.blade.php @@ -0,0 +1,62 @@ +<table class="table-hover table-fix-action m-0 table"> + @if (count($homepageModels) > 0) + <thead> + @include('bo.modules.table-col-sorter', [ + 'cols' => [ + 'title_part1' => Str::ucfirst(__('validation.custom.title_part1')), + 'title_part2' => Str::ucfirst(__('validation.custom.title_part2')), + 'title_part3' => Str::ucfirst(__('validation.custom.title_part3')), + 'picture' => Str::ucfirst(__('validation.custom.picture')), + 'presentation_title' => Str::ucfirst(__('validation.custom.presentation_title')), + 'presentation_content' => Str::ucfirst(__('validation.attributes.content')), + 'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')), + ], + ]) + </thead> + <tbody> + @foreach ($homepageModels as $homepageModel) + <tr class="border-bottom list-item"> + <td class="text-center align-middle">{{ $homepageModel->title_part1 }}</td> + <td class="text-center align-middle">{{ $homepageModel->title_part2 }}</td> + <td class="text-center align-middle">{{ $homepageModel->title_part3 }}</td> + <td class="text-center align-middle"> + <img src="{{ asset($homepageModel->picture) }}" title="{{ $homepageModel->picture_title }}" + alt="{{ $homepageModel->picture_alt }}" height="50px"> + </td> + <td class="text-center align-middle">{{ $homepageModel->presentation_title }}</td> + <td class="text-center align-middle">{!! Str::limit($homepageModel->presentation_content, 100) !!}</td> + <td class="text-center align-middle"> + <span class="badge bg-secondary">{{ $homepageModel->updated_at->isoFormat('LLLL') }}</span> + </td> + @php + $routeName = request() + ->route() + ->getName(); + @endphp + <td class="text-end align-middle"> + @canAny(['update'], $homepageModel) + <form class="btn-group confirmDeleteTS" action="{{ route('bo.homepages.edit', $homepageModel) }}" method="POST" + novalidate> + @can('update', $homepageModel) + <a class="btn btn-sm btn-primary" data-bs-toggle="tooltip" + href="{{ route('bo.homepages.edit', ['homepage' => $homepageModel]) }}" + title="{{ Str::ucfirst(__('crud.actions.update')) }}"> + <i class="fa-solid fa-pencil"></i> + </a> + @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.homepage')]) }}</td> + </tr> + @endif +</table> diff --git a/resources/views/bo/pages/homepages/index.blade.php b/resources/views/bo/pages/homepages/index.blade.php new file mode 100644 index 0000000..4554bcd --- /dev/null +++ b/resources/views/bo/pages/homepages/index.blade.php @@ -0,0 +1,16 @@ +@extends('bo.layout') + +@section('title', + Str::of(__('models.classes.homepage'))->plural()->ucfirst()) +@section('description', trans_choice('crud.meta.description.index', 0, ['model' => Str::plural(__('models.classes.homepage'))])) + +@section('content') + <div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap"> + @include('modules.breadcrumbs.breadcrumb-body') + </div> + @include('bo.modules.search-bar') + <div class="table-responsive mb-3"> + @include('bo.pages.homepages.index-list') + </div> + {{ $homepageModels->links() }} +@endsection diff --git a/routes/breadcrumbs-bo.php b/routes/breadcrumbs-bo.php index e5f2181..0b6fe4e 100644 --- a/routes/breadcrumbs-bo.php +++ b/routes/breadcrumbs-bo.php @@ -2,6 +2,7 @@ use App\Models\ActivityLog; use App\Models\Commitment; +use App\Models\Homepage; use App\Models\Range; use App\Models\News; use App\Models\SeasonalSection; @@ -136,6 +137,18 @@ Breadcrumbs::for('bo.seasonalsections.duplicate', function (Generator $trail) { $trail->push(Str::ucfirst(trans('crud.actions.duplicate'))); }); +// * HOMEPAGES +Breadcrumbs::for('bo.homepages.index', function (Generator $trail) { + $trail->push( + Str::of(trans('models.classes.homepage'))->plural()->ucfirst(), + route('bo.homepages.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc']) + ); +}); +Breadcrumbs::for('bo.homepages.edit', function (Generator $trail, Homepage $homepage) { + $trail->parent('bo.homepages.index'); + $trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.homepages.edit', $homepage)); +}); + // * STAMPS Breadcrumbs::for('bo.stamps.index', function (Generator $trail) { $trail->push( diff --git a/routes/web-bo.php b/routes/web-bo.php index 8dea6a0..1ac7e40 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -3,6 +3,7 @@ use App\Http\Controllers\Bo\ActivityLogsController; use App\Http\Controllers\Bo\CommitmentController; use App\Http\Controllers\Bo\DashboardController; +use App\Http\Controllers\Bo\HomepageController; use App\Http\Controllers\Bo\NewsController; use App\Http\Controllers\Bo\StaticPageController; use App\Http\Controllers\Bo\RangeController; @@ -106,6 +107,11 @@ Route::prefix('bo') SeasonalSectionController::class, 'duplicate' ])->name('seasonalsections.duplicate'); + // * HOMEPAGE + Route::resource('homepages', HomepageController::class)->only(['index', 'edit', 'update']) + ->withoutMiddleware('htmlsanitize') + ->middleware('htmlsanitize:presentation_content'); + // * RANGES. Route::resource('stamps', StampController::class)->except('show') ->withoutMiddleware('htmlsanitize')