diff --git a/app/Http/Controllers/Bo/ExplorerpageController.php b/app/Http/Controllers/Bo/ExplorerpageController.php new file mode 100644 index 0000000..3b0adf3 --- /dev/null +++ b/app/Http/Controllers/Bo/ExplorerpageController.php @@ -0,0 +1,95 @@ +authorizeResource(Explorerpage::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 $explorerpageModels */ + $explorerpageModels = Explorerpage::query(); + + /** @var string $search Search field */ + $search = $request->search; + if ($search) { + $this->searchQuery( + $explorerpageModels, + $search, + null, + 'picture_1_title', + 'picture_2_title', + 'picture_3_title' + ); + } + $searchFields = \implode(', ', [ + Str::ucfirst(trans('validation.attributes.title')) + ]); + + /** Sort columns with a query */ + $this->sortQuery($explorerpageModels); + + /** Custom pagination */ + $explorerpageModels = $this->paginate($explorerpageModels); + + return view('bo.pages.explorerpages.index', compact('explorerpageModels', 'search', 'searchFields')); + } + + /** + * Show the form for editing the specified resource. + * + * @param App\Models\Explorerpage $explorerpage + * @return \Illuminate\Contracts\View\View + */ + public function edit(Explorerpage $explorerpage): \Illuminate\Contracts\View\View + { + return view('bo.pages.explorerpages.edit', ['explorerpageModel' => $explorerpage]); + } + + /** + * Update the specified resource in storage. + * + * @param \App\Http\Requests\Bo\Explorerpages\UpdateExplorerpageRequest $request + * @param \App\Models\Explorerpage $explorerpage + * @return \Illuminate\Http\RedirectResponse + */ + public function update( + UpdateExplorerpageRequest $request, + Explorerpage $explorerpage + ): \Illuminate\Http\RedirectResponse { + return DB::transaction(function () use ($request, $explorerpage) { + $explorerpage->fill($request->validated()); + + if ($explorerpage->saveOrFail()) { + return redirect()->route('bo.explorerpages.edit', $explorerpage) + ->with('success', __('crud.messages.has_been_updated', [ + 'model' => Str::ucfirst(__('models.classes.explorerpage')) + ])); + } + return redirect()->route('bo.explorerpages.edit', $explorerpage) + ->with('error', __('crud.messages.cannot_be_updated', [ + 'model' => Str::ucfirst(__('models.classes.explorerpage')) + ])); + }); + } +} diff --git a/app/Http/Requests/Bo/Explorerpage/StoreExplorerpageRequest.php b/app/Http/Requests/Bo/Explorerpage/StoreExplorerpageRequest.php new file mode 100644 index 0000000..1c91365 --- /dev/null +++ b/app/Http/Requests/Bo/Explorerpage/StoreExplorerpageRequest.php @@ -0,0 +1,57 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation() + { + $this->mergePicture('picture_1'); + $this->mergePicture('picture_2'); + $this->mergePicture('picture_3'); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + $rules = [ + 'picture_1_alt' => 'required|string|between:3,255', + 'picture_1_title' => 'required|string|between:3,255', + 'picture_2_alt' => 'required|string|between:3,255', + 'picture_2_title' => 'required|string|between:3,255', + 'picture_3_alt' => 'required|string|between:3,255', + 'picture_3_title' => 'required|string|between:3,255', + ]; + + return \array_merge( + $rules, + $this->pictureRules('picture_1', 265, 364, 265, 364, false), + $this->pictureRules('picture_2', 265, 364, 265, 364, false), + $this->pictureRules('picture_3', 265, 364, 265, 364, false), + ); + } +} diff --git a/app/Http/Requests/Bo/Explorerpage/UpdateExplorerpageRequest.php b/app/Http/Requests/Bo/Explorerpage/UpdateExplorerpageRequest.php new file mode 100644 index 0000000..d2762e4 --- /dev/null +++ b/app/Http/Requests/Bo/Explorerpage/UpdateExplorerpageRequest.php @@ -0,0 +1,18 @@ + 'stamp', 'commitment' => 'commitment', 'range' => 'range', - 'homepage' => 'homepage' + 'homepage' => 'home page', + 'explorerpage' => 'explorer page', ] ]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index df49a2e..49aab12 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -242,6 +242,9 @@ return [ 'unpublish_at' => 'end of publication date', 'background' => 'background', 'picture' => 'picture', + 'picture_1' => 'picture one', + 'picture_2' => 'picture two', + 'picture_3' => 'picture three', 'presentation_title' => 'presentation title', 'title_part1' => 'title part one', 'title_part2' => 'title part two', diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index 3dc2ec3..f5661eb 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -11,5 +11,6 @@ return [ 'homepage' => 'page d\'accueil', 'news' => 'actualité', 'stamp' => 'tampon', + 'explorerpage' => 'page explorateur', ] ]; diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index b86718c..679e364 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -244,6 +244,9 @@ return [ 'unpublish_at' => 'date de fin de publication', 'background' => 'fond', 'picture' => 'image', + 'picture_1' => 'image une', + 'picture_2' => 'image deux', + 'picture_3' => 'image trois', 'presentation_title' => 'titre de présentation', 'title_part1' => 'première partie du titre', 'title_part2' => 'seconde partie du titre', diff --git a/resources/views/bo/layouts/nav-list.blade.php b/resources/views/bo/layouts/nav-list.blade.php index 8a40904..1bba1c8 100644 --- a/resources/views/bo/layouts/nav-list.blade.php +++ b/resources/views/bo/layouts/nav-list.blade.php @@ -53,7 +53,7 @@
  • + title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.homepage'))->plural()]) }}"> {{ Str::of(__('models.classes.homepage'))->plural()->ucfirst() }}
  • @@ -66,11 +66,12 @@ @endcan - @can('viewAny', \App\Models\News::class) -
  • + + {{ Str::of(__('models.classes.explorerpage'))->plural()->ucfirst() }}
  • @endcan diff --git a/resources/views/bo/pages/explorerpages/edit.blade.php b/resources/views/bo/pages/explorerpages/edit.blade.php new file mode 100644 index 0000000..b465aff --- /dev/null +++ b/resources/views/bo/pages/explorerpages/edit.blade.php @@ -0,0 +1,39 @@ +@extends('bo.layout', ['brParam' => $explorerpageModel]) + +@section('title', trans_choice('crud.meta.title.edit', 0, ['model' => __('models.classes.explorerpage')])) +@section('description', trans_choice('crud.meta.description.edit', 0, ['model' => __('models.classes.explorerpage')])) +@section('breadcrumb', + request()->route()->getName()) + +@section('content') +
    +
    + + + + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $explorerpageModel]) +
    +
    +
    + +
    +
    +
    +
    + @csrf + @method('PUT') + @include('bo.pages.explorerpages.form') +
    +
    + +
    +
    +
    +@endsection diff --git a/resources/views/bo/pages/explorerpages/form.blade.php b/resources/views/bo/pages/explorerpages/form.blade.php new file mode 100644 index 0000000..8f344fb --- /dev/null +++ b/resources/views/bo/pages/explorerpages/form.blade.php @@ -0,0 +1,243 @@ +
    + {{-- PICTURE 1 --}} +
    +
    + {{ Str::ucfirst(__('validation.custom.picture')) }} +
    + {{-- PICTURE_1_ALT --}} +
    + @include('bo.partials.inputs.varchar', [ + 'id' => 'explorerpagePicture1Alt', + '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.explorerpage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_1_alt', + 'required' => true, + 'model' => $explorerpageModel ?? 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.explorerpage'), + ]), + ]) +
    + {{-- PICTURE_1_TITLE --}} +
    + @include('bo.partials.inputs.varchar', [ + 'id' => 'explorerpagePicture1Title', + '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.explorerpage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_1_title', + 'required' => true, + 'model' => $explorerpageModel ?? 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.explorerpage'), + ]), + ]) +
    + {{-- PICTURE_1 --}} +
    + @include('bo.partials.inputs.varchar-picture', [ + 'id' => 'explorerpagePicture1', + 'name' => 'picture_1', + 'width' => 265, + 'height' => 364, + 'model' => $explorerpageModel ?? null, + 'helper' => __('crud.minicrud.dimensions_must_be', [ + 'widthpx' => '265px', + 'heightpx' => '364px', + ]), + 'required' => true, + 'preview' => true, + ]) +
    +
    +
    +
    + {{-- PICTURE 2 --}} +
    +
    + {{ Str::ucfirst(__('validation.custom.picture')) }} +
    + {{-- PICTURE_2_ALT --}} +
    + @include('bo.partials.inputs.varchar', [ + 'id' => 'explorerpagePicture2Alt', + '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.explorerpage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_2_alt', + 'required' => true, + 'model' => $explorerpageModel ?? 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.explorerpage'), + ]), + ]) +
    + {{-- PICTURE_2_TITLE --}} +
    + @include('bo.partials.inputs.varchar', [ + 'id' => 'explorerpagePicture2Title', + '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.explorerpage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_2_title', + 'required' => true, + 'model' => $explorerpageModel ?? 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.explorerpage'), + ]), + ]) +
    + {{-- PICTURE_2 --}} +
    + @include('bo.partials.inputs.varchar-picture', [ + 'id' => 'explorerpagePicture2', + 'name' => 'picture_2', + 'width' => 265, + 'height' => 364, + 'model' => $explorerpageModel ?? null, + 'helper' => __('crud.minicrud.dimensions_must_be', [ + 'widthpx' => '265px', + 'heightpx' => '364px', + ]), + 'required' => true, + 'preview' => true, + ]) +
    +
    +
    +
    + {{-- PICTURE 3 --}} +
    +
    + {{ Str::ucfirst(__('validation.custom.picture')) }} +
    + {{-- PICTURE_3_ALT --}} +
    + @include('bo.partials.inputs.varchar', [ + 'id' => 'explorerpagePicture3Alt', + '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.explorerpage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_3_alt', + 'required' => true, + 'model' => $explorerpageModel ?? 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.explorerpage'), + ]), + ]) +
    + {{-- PICTURE_3_TITLE --}} +
    + @include('bo.partials.inputs.varchar', [ + 'id' => 'explorerpagePicture3Title', + '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.explorerpage'), + ]), + 'hasWordCounter' => true, + 'name' => 'picture_3_title', + 'required' => true, + 'model' => $explorerpageModel ?? 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.explorerpage'), + ]), + ]) +
    + {{-- PICTURE --}} +
    + @include('bo.partials.inputs.varchar-picture', [ + 'id' => 'explorerpagePicture3', + 'name' => 'picture_3', + 'width' => 265, + 'height' => 364, + 'model' => $explorerpageModel ?? null, + 'helper' => __('crud.minicrud.dimensions_must_be', [ + 'widthpx' => '265px', + 'heightpx' => '364px', + ]), + 'required' => true, + 'preview' => true, + ]) +
    +
    +
    +
    +
    +
    +

    * {{ __('crud.helpers.required_fields') }}

    +
    +
    +
    + +@push('scripts') + +@endpush diff --git a/resources/views/bo/pages/explorerpages/index-list.blade.php b/resources/views/bo/pages/explorerpages/index-list.blade.php new file mode 100644 index 0000000..a99951e --- /dev/null +++ b/resources/views/bo/pages/explorerpages/index-list.blade.php @@ -0,0 +1,68 @@ + + @if (count($explorerpageModels) > 0) + + @include('bo.modules.table-col-sorter', [ + 'cols' => [ + 'picture_1' => Str::ucfirst(__('validation.custom.picture_1')), + 'picture_1_title' => Str::ucfirst(__('validation.attributes.title')), + 'picture_2' => Str::ucfirst(__('validation.custom.picture_2')), + 'picture_2_title' => Str::ucfirst(__('validation.attributes.title')), + 'picture_3' => Str::ucfirst(__('validation.custom.picture_3')), + 'picture_3_title' => Str::ucfirst(__('validation.attributes.title')), + 'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')), + ], + ]) + + + @foreach ($explorerpageModels as $explorerpageModel) + + + + + + + + + @php + $routeName = request() + ->route() + ->getName(); + @endphp + + + @endforeach + + @else + + + + @endif +
    + {{ $explorerpageModel->picture_1_alt }} + {{ $explorerpageModel->picture_1_title }}1 + {{ $explorerpageModel->picture_2_alt }} + {{ $explorerpageModel->picture_2_title }}2 + {{ $explorerpageModel->picture_3_alt }} + {{ $explorerpageModel->picture_3_title }} + {{ $explorerpageModel->updated_at->isoFormat('LLLL') }} + + @canAny(['update'], $explorerpageModel) +
    + @can('update', $explorerpageModel) + + + + @endcan +
    + @else + + + + @endcan +
    {{ __('crud.other.no_model_found', ['model' => __('models.classes.explorerpage')]) }}
    diff --git a/resources/views/bo/pages/explorerpages/index.blade.php b/resources/views/bo/pages/explorerpages/index.blade.php new file mode 100644 index 0000000..1afb8b8 --- /dev/null +++ b/resources/views/bo/pages/explorerpages/index.blade.php @@ -0,0 +1,16 @@ +@extends('bo.layout') + +@section('title', + Str::of(__('models.classes.explorerpage'))->plural()->ucfirst()) +@section('description', trans_choice('crud.meta.description.index', 0, ['model' => Str::plural(__('models.classes.explorerpage'))])) + +@section('content') +
    + @include('modules.breadcrumbs.breadcrumb-body') +
    + @include('bo.modules.search-bar') +
    + @include('bo.pages.explorerpages.index-list') +
    + {{ $explorerpageModels->links() }} +@endsection diff --git a/routes/breadcrumbs-bo.php b/routes/breadcrumbs-bo.php index 0b6fe4e..84a113e 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\Explorerpage; use App\Models\Homepage; use App\Models\Range; use App\Models\News; @@ -149,6 +150,18 @@ Breadcrumbs::for('bo.homepages.edit', function (Generator $trail, Homepage $home $trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.homepages.edit', $homepage)); }); +// * EXPLORERPAGES +Breadcrumbs::for('bo.explorerpages.index', function (Generator $trail) { + $trail->push( + Str::of(trans('models.classes.explorerpage'))->plural()->ucfirst(), + route('bo.explorerpages.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc']) + ); +}); +Breadcrumbs::for('bo.explorerpages.edit', function (Generator $trail, Explorerpage $explorerpage) { + $trail->parent('bo.explorerpages.index'); + $trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.explorerpages.edit', $explorerpage)); +}); + // * STAMPS Breadcrumbs::for('bo.stamps.index', function (Generator $trail) { $trail->push( diff --git a/routes/web-bo.php b/routes/web-bo.php index 1ac7e40..686729a 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\ExplorerpageController; use App\Http\Controllers\Bo\HomepageController; use App\Http\Controllers\Bo\NewsController; use App\Http\Controllers\Bo\StaticPageController; @@ -112,7 +113,7 @@ Route::prefix('bo') ->withoutMiddleware('htmlsanitize') ->middleware('htmlsanitize:presentation_content'); - // * RANGES. + // * STAMPS Route::resource('stamps', StampController::class)->except('show') ->withoutMiddleware('htmlsanitize') ->middleware('htmlsanitize:description'); @@ -126,19 +127,9 @@ Route::prefix('bo') StampController::class, 'duplicate' ])->name('stamps.duplicate'); - // * NEWS. - Route::resource('news', NewsController::class)->except('show') - ->withoutMiddleware('htmlsanitize') - ->middleware('htmlsanitize:content'); - Route::patch('/news/{news}/change-published', [ - NewsController::class, 'changePublished' - ])->name('news.change-published'); - Route::patch('/news/{news}/change-order/{direction}', [ - RangeController::class, 'changeOrder' - ])->where('direction', 'up|down')->name('news.change-order'); - Route::get('/news/{news}/duplicate', [ - NewsController::class, 'duplicate' - ])->name('news.duplicate'); + // * EXPLORERPAGE + Route::resource('explorerpages', ExplorerpageController::class)->only(['index', 'edit', 'update']) + ->withoutMiddleware('htmlsanitize'); Route::middleware('can:isConceptor')->group(function () { // * ACTIVITY LOGS.