Added Testimonials CRUD

This commit is contained in:
Noah Lancien 2023-11-27 12:43:20 +01:00
parent afd5b4b47e
commit 93dc9903c5
14 changed files with 829 additions and 0 deletions

View file

@ -0,0 +1,165 @@
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Testimonials\StoreTestimonialRequest;
use App\Http\Requests\Bo\Testimonials\UpdateTestimonialRequest;
use App\Models\Testimonial;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class TestimonialController extends Controller
{
/**
* Create the controller instance.
*/
public function __construct()
{
$this->authorizeResource(Testimonial::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 $testimonialModels */
$testimonialModels = Testimonial::query();
/** @var string $search Search field */
$search = $request->search;
if ($search) {
$this->searchQuery(
$testimonialModels,
$search,
null,
'name',
'job',
'content',
'type',
);
}
$searchFields = \implode(', ', [
Str::ucfirst(trans('validation.attributes.name')),
trans('validation.custom.job'),
trans('validation.attributes.content'),
trans('validation.custom.type'),
]);
/** Sort columns with a query */
$this->sortQuery($testimonialModels);
/** Custom pagination */
$testimonialModels = $this->paginate($testimonialModels);
return view('bo.pages.testimonials.index', compact('testimonialModels', 'search', 'searchFields'));
}
/**
* Show the form for creating a new resource.
*
* @param \App\Models\Testimonial $testimonial
* @return \Illuminate\Contracts\View\View
*/
public function create(Testimonial $testimonial): \Illuminate\Contracts\View\View
{
return view('bo.pages.testimonials.create', ['testimonialModel' => $testimonial]);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Bo\Testimonials\StoreTestimonialRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(StoreTestimonialRequest $request): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request) {
$testimonial = new Testimonial();
if ($testimonial->fill($request->validated())->saveOrFail()) {
return redirect()->route('bo.testimonials.edit', $testimonial)
->with('success', __('crud.messages.has_been_created', [
'model' => Str::ucfirst(__('models.classes.testimonial'))
]));
}
return redirect()->back()
->with('error', __('crud.messages.cannot_be_created', [
'model' => Str::ucfirst(__('models.classes.testimonial'))
]));
});
}
/**
* Show the form for editing the specified resource.
*
* @param App\Models\Testimonial $testimonial
* @return \Illuminate\Contracts\View\View
*/
public function edit(Testimonial $testimonial): \Illuminate\Contracts\View\View
{
return view('bo.pages.testimonials.edit', ['testimonialModel' => $testimonial]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Bo\Testimonials\UpdateTestimonialRequest $request
* @param \App\Models\Testimonial $testimonial
* @return \Illuminate\Http\RedirectResponse
*/
public function update(
UpdateTestimonialRequest $request,
Testimonial $testimonial
): \Illuminate\Http\RedirectResponse {
return DB::transaction(function () use ($request, $testimonial) {
if ($testimonial->fill($request->validated())->saveOrFail()) {
return redirect()->route('bo.testimonials.edit', $testimonial)
->with('success', __('crud.messages.has_been_updated', [
'model' => Str::ucfirst(__('models.classes.testimonial'))
]));
}
return redirect()->route('bo.testimonials.edit', $testimonial)
->with('error', __('crud.messages.cannot_be_updated', [
'model' => Str::ucfirst(__('models.classes.testimonial'))
]));
});
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Testimonial $testimonial
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Testimonial $testimonial): \Illuminate\Http\RedirectResponse
{
if ($testimonial->deleteOrFail()) {
return redirect()->route('bo.testimonials.index')
->with('success', __('crud.messages.has_been_deleted', [
'model' => Str::ucfirst(__('models.classes.testimonial'))
]));
}
return redirect()->back()
->with('error', __('crud.messages.cannot_be_deleted', [
'model' => Str::ucfirst(__('models.classes.testimonial'))
]));
}
/**
* Duplicate the specified resource.
*
* @param \App\Models\Testimonial $testimonial
* @return \Illuminate\Contracts\View\View
*/
public function duplicate(Testimonial $testimonial): \Illuminate\Contracts\View\View
{
return $this->create($testimonial->replicate());
}
}

View file

@ -0,0 +1,82 @@
<?php
namespace App\Http\Requests\Bo\Testimonials;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class StoreTestimonialRequest 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->mergePicture('picture');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
$rules = [
'type' => [
'required',
new Enum(\App\Enums\Testimonials\TypeEnum::class)
],
'name' => 'required|string|between:3,255',
'job' => 'required|string|between:3,255',
'content' => 'required|string|min:3',
'picture_alt' => 'required|string|between:3,255',
'picture_title' => 'required|string|between:3,255',
];
return \array_merge(
$rules,
// FIXME: Mettre à jour les tailles.
$this->pictureRules('picture', 100, 100, 100, 100, null, false),
);
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'type' => __('validation.custom.type'),
'name' => __('validation.attributes.name'),
'job' => __('validation.custom.job'),
'content' => __('validation.attributes.content'),
'picture_alt' => __(':field :inter:model', [
'field' => __('validation.custom.alt_attribute'),
'inter' => __('validation.custom.of_the.vowel'),
'model' => __('validation.custom.picture'),
]),
'picture_title' => __(':field :inter:model', [
'field' => __('validation.custom.title_attribute'),
'inter' => __('validation.custom.of_the.vowel'),
'model' => __('validation.custom.picture'),
]),
];
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Http\Requests\Bo\Testimonials;
class UpdateTestimonialRequest extends StoreTestimonialRequest
{
}

View file

@ -0,0 +1,120 @@
<?php
namespace App\Policies;
use App\Enums\Users\RoleEnum;
use App\Models\User;
use App\Policies\Rules\UserStaticRules;
class TestimonialPolicy
{
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function viewAny(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function view(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can create models.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function create(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function update(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function delete(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can restore the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function restore(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can permanently delete the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function forceDelete(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can duplicate the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function duplicate(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can publish/unpublish the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function changePublished(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Determine whether the user can change the order of the model.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function changeOrder(User $authUser): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
}

View file

@ -13,5 +13,6 @@ return [
'slide' => 'slide',
'job_video' => 'vidéo métier|vidéos métiers',
'strip' => 'bandeau d\'information|bandeaux d\'information',
'testimonial' => 'témoignage',
]
];

View file

@ -271,5 +271,8 @@ return [
'youtube_video' => 'vidéo YouTube',
'slider' => 'slider',
'place' => 'lieu',
'job' => 'métier',
'type' => 'type',
'person' => 'personne',
],
];

View file

@ -93,6 +93,15 @@
</a>
</li>
@endcan
@can('viewAny', \App\Models\Testimonial::class)
<li class="nav-item">
<a class="nav-link @if (request()->routeIs('bo.testimonials.*')) active @endif" data-bs-toggle="tooltip"
href="{{ route('bo.testimonials.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => Str::of(__('models.classes.testimonial'))->title()]) }}">
{{ Str::of(__('models.classes.testimonial'))->ucfirst()->plural() }}
</a>
</li>
@endcan
@can('viewAny', \App\Models\JobVideo::class)
<li class="nav-item">
<a class="nav-link @if (request()->routeIs('bo.jobvideos.*')) active @endif" data-bs-toggle="tooltip"

View file

@ -0,0 +1,36 @@
@extends('bo.layout', ['brParam' => $testimonialModel])
@section('title', __('Création d\'un :model', ['model' => __('models.classes.testimonial')]))
@section('description', __('Création d\'un tout nouveau :model', ['model' => __('models.classes.testimonial')]))
@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.testimonials.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.testimonial')]) }}">
<i class="fa-solid fa-arrow-left"></i>
</a>
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $testimonialModel])
</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.testimonial')]) }}">
{{ Str::ucfirst(__('crud.actions.save')) }}
</button>
</div>
</div>
<form action="{{ route('bo.testimonials.store') }}" method="POST" enctype="multipart/form-data">
@csrf
@include('bo.pages.testimonials.form')
<div class="row mt-3">
<div class="col text-center">
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.testimonial')]) }}">
{{ Str::ucfirst(__('crud.actions.save')) }}
</button>
</div>
</div>
</form>
@endsection

View file

@ -0,0 +1,53 @@
@extends('bo.layout', ['brParam' => $testimonialModel])
@section('title', __('Édition d\'une :model', ['model' => __('models.classes.testimonial')]))
@section('description', __('Édition d\'une :model déjà existante', ['model' => __('models.classes.testimonial')]))
@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.testimonials.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.testimonial'))]) }}">
<i class="fa-solid fa-arrow-left"></i>
</a>
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $testimonialModel])
</div>
<div class="mb-md-0 mb-2">
<form class="btn-group confirmDeleteTS" action="{{ route('bo.testimonials.destroy', $testimonialModel) }}" method="POST" novalidate>
@can('duplicate', $testimonialModel)
<a class="btn btn-secondary" data-bs-toggle="tooltip"
href="{{ route('bo.testimonials.duplicate', ['testimonial' => $testimonialModel]) }}"
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.testimonial')]) }}">
{{ Str::ucfirst(__('crud.actions.save')) }}
</button>
@can('delete', $testimonialModel)
@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.testimonials.update', $testimonialModel) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
@include('bo.pages.testimonials.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.testimonial')]) }}">
{{ Str::ucfirst(__('crud.actions.save')) }}
</button>
</div>
</div>
</form>
@endsection

View file

@ -0,0 +1,228 @@
<div class="row">
{{-- TYPE --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.custom.type')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.tinyint-enum', [
'id' => 'testimonialType',
'label' => __('Associer un type'),
'name' => 'type',
'model' => $testimonialModel ?? null,
'required' => true,
'associatedModels' => \App\Enums\Testimonials\TypeEnum::toArray(),
'helper' => __('Sélectionnez un type dans la liste déroulante.'),
])
</div>
</div>
</fieldset>
</div>
{{-- NAME --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.attributes.name')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialName',
'label' => __(':field :inter:model', [
'field' => Str::ucfirst(__('validation.attributes.name')),
'inter' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'hasWordCounter' => true,
'name' => 'name',
'required' => true,
'model' => $testimonialModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __(':field :inter:model', [
'field' => __('validation.attributes.name'),
'inter' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'min' => 3,
'max' => 255,
]),
'placeholder' => __('Le nom de la personne'),
])
</div>
</div>
</fieldset>
</div>
{{-- JOB --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.custom.job')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialJob',
'label' => __(':field :inter:model', [
'field' => Str::ucfirst(__('validation.custom.job')),
'inter' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'hasWordCounter' => true,
'name' => 'job',
'required' => false,
'model' => $testimonialModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __(':field :inter1:person :inter2:model', [
'field' => __('validation.custom.job'),
'inter1' => __('validation.custom.of_the.female'),
'person' => __('validation.custom.person'),
'inter2' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'min' => 3,
'max' => 255,
]),
'placeholder' => __('Le métier de la personne témoignant'),
])
</div>
</div>
</fieldset>
</div>
{{-- CONTENT --}}
<div class="col-12 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.attributes.content')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.text-html', [
'id' => 'testimonialContent',
'label' => __(':field :inter:model', [
'field' => Str::ucfirst(__('validation.attributes.content')),
'inter' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'name' => 'content',
'model' => $testimonialModel ?? null,
'editorConfig' => \App\Enums\CkEditorConfigName::base->name(),
'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' => 'testimonialPictureAlt',
'label' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.alt_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'hasWordCounter' => true,
'name' => 'picture_alt',
'required' => true,
'model' => $testimonialModel ?? null,
'helper' => __('crud.minicrud.picture_alt_helper'),
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.alt_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
])
</div>
{{-- PICTURE_TITLE --}}
<div class="col-12 col-md-6 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialPictureTitle',
'label' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.title_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
'hasWordCounter' => true,
'name' => 'picture_title',
'required' => true,
'model' => $testimonialModel ?? null,
'helper' => __('crud.minicrud.picture_title_helper'),
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.title_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => __('models.classes.testimonial'),
]),
])
</div>
{{-- PICTURE --}}
<div class="col-12">
@include('bo.partials.inputs.varchar-picture', [
'id' => 'testimonialPicture',
'name' => 'picture',
'width' => 100,
'height' => 100,
'model' => $testimonialModel ?? null,
'helper' => __('crud.minicrud.dimensions_must_be', [
'widthpx' => '100px',
'heightpx' => '100px',
]),
'required' => true,
'preview' => true,
])
</div>
</div>
</fieldset>
</div>
</div>
<div class="row">
<div class="col text-center">
<p><b>* {{ __('crud.helpers.required_fields') }}</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('');
})
// Update inputs for testimonialrs other than 'home'.
const testimonialrInput = document.getElementById('testimonialr');
const videoIdField = document.getElementById('video_id_input');
const titleInput = document.getElementById('testimonialTitle');
if (testimonialrInput.value === "{{ \App\Enums\Slides\SliderTypeEnum::home->value() }}") {
videoIdField.hidden = false;
titleInput.required = false;
} else {
videoIdField.hidden = true;
titleInput.required = true;
}
testimonialrInput.addEventListener('input', () => {
if (testimonialrInput.value === "{{ \App\Enums\Slides\SliderTypeEnum::home->value() }}") {
videoIdField.hidden = false;
titleInput.required = false;
} else {
videoIdField.hidden = true;
titleInput.required = true;
}
})
});
</script>
@endpush

View file

@ -0,0 +1,75 @@
<table class="table-hover table-fix-action m-0 table">
@if (count($testimonialModels) > 0)
<thead>
@include('bo.modules.table-col-sorter', [
'cols' => [
'type' => Str::ucfirst(__('validation.custom.type')),
'name' => Str::ucfirst(__('validation.attributes.name')),
'job' => Str::ucfirst(__('validation.custom.job')),
'updated_at' => Str::ucfirst(__('validation.attributes.updated_at')),
],
])
</thead>
<tbody>
@foreach ($testimonialModels as $testimonialModel)
<tr class="border-bottom list-item">
<td class="text-center align-middle">{{ $testimonialModel->type->label() }}</td>
<td class="text-center align-middle">{{ $testimonialModel->name }}</td>
<td class="text-center align-middle">{{ $testimonialModel->job }}</td>
@php
$routeName = request()
->route()
->getName();
@endphp
@if (empty(request()->search) && Session::get("$routeName.sort_col") === 'order')
@include('bo.modules.change-model-order', [
'routeName' => 'testimonials',
'model' => $testimonialModel,
'models' => $testimonialModels,
])
@endif
<td class="text-center align-middle">
<span class="badge bg-secondary">{{ $testimonialModel->updated_at->isoFormat('LLLL') }}</span>
</td>
<td class="text-end align-middle">
@canAny(['delete', 'duplicate', 'update'], $testimonialModel)
<form class="btn-group confirmDeleteTS" action="{{ route('bo.testimonials.destroy', $testimonialModel) }}"
method="POST" novalidate>
@can('duplicate', $testimonialModel)
<a class="btn btn-sm btn-secondary" data-bs-toggle="tooltip"
href="{{ route('bo.testimonials.duplicate', ['testimonial' => $testimonialModel]) }}"
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
<i class="fa-solid fa-copy"></i>
</a>
@endcan
@can('update', $testimonialModel)
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
href="{{ route('bo.testimonials.edit', ['testimonial' => $testimonialModel]) }}"
title="{{ Str::ucfirst(__('crud.actions.update')) }}">
<i class="fa-solid fa-pencil"></i>
</a>
@endcan
@can('delete', $testimonialModel)
@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.testimonial')]) }}</td>
</tr>
@endif
</table>

View file

@ -0,0 +1,21 @@
@extends('bo.layout')
@section('title', Str::ucfirst(__('models.classes.testimonial')))
@section('description', __('Liste de tous les :model', ['model' => Str::plural(__('models.classes.testimonial'))]))
@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\Testimonial::class)
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" href="{{ route('bo.testimonials.create') }}"
title="{{ __('crud.helpers.create_model', ['model' => __('models.classes.testimonial')]) }}">
<i class="fa-solid fa-plus"></i>
</a>
@endcan
</div>
@include('bo.modules.search-bar')
<div class="table-responsive mb-3">
@include('bo.pages.testimonials.index-list')
</div>
{{ $testimonialModels->links() }}
@endsection

View file

@ -10,6 +10,7 @@ use App\Models\Site;
use App\Models\Slide;
use App\Models\StaticPage;
use App\Models\Strip;
use App\Models\Testimonial;
use App\Models\User;
use Diglactic\Breadcrumbs\Breadcrumbs;
use Diglactic\Breadcrumbs\Generator;
@ -199,6 +200,26 @@ Breadcrumbs::for('bo.strips.duplicate', function (Generator $trail) {
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
});
// * TESTIMONIALS
Breadcrumbs::for('bo.testimonials.index', function (Generator $trail) {
$trail->push(
Str::of(trans('models.classes.testimonial'))->plural()->ucfirst(),
route('bo.testimonials.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc'])
);
});
Breadcrumbs::for('bo.testimonials.create', function (Generator $trail) {
$trail->parent('bo.testimonials.index');
$trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.testimonials.create'));
});
Breadcrumbs::for('bo.testimonials.edit', function (Generator $trail, Testimonial $testimonial) {
$trail->parent('bo.testimonials.index');
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.testimonials.edit', $testimonial));
});
Breadcrumbs::for('bo.testimonials.duplicate', function (Generator $trail) {
$trail->parent('bo.testimonials.index');
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
});
// * SECTIONS
Breadcrumbs::for('bo.sections.index', function (Generator $trail) {
$trail->push(

View file

@ -11,6 +11,7 @@ use App\Http\Controllers\Bo\SiteController;
use App\Http\Controllers\Bo\SlideController;
use App\Http\Controllers\Bo\StaticPageController;
use App\Http\Controllers\Bo\StripController;
use App\Http\Controllers\Bo\TestimonialController;
use App\Http\Controllers\Bo\UploadController;
use App\Http\Controllers\Bo\UserController;
use App\Http\Controllers\Controller;
@ -123,6 +124,13 @@ Route::prefix('bo')
JobVideoController::class, 'duplicate'
])->name('jobvideos.duplicate');
// * TESTIMONIALS.
Route::resource('testimonials', TestimonialController::class)->except('show')
->withoutMiddleware('htmlsanitize')
->middleware('htmlsanitize:content');
Route::get('/testimonials/{testimonial}/duplicate', [
TestimonialController::class, 'duplicate'
])->name('testimonials.duplicate');
Route::middleware('can:isConceptor')->group(function () {
// * ACTIVITY LOGS.