feat: ✨ add static pages crud for rgpd content

This commit is contained in:
Nicolas Demangeat 2025-03-12 09:46:06 +01:00 • committed by Alexis Gousseau
parent fc7b88adbf
commit e93cb4e41f
23 changed files with 689 additions and 93 deletions

View file

@ -13,8 +13,6 @@ enum GeneralConfigType: int
case demarche = 3;
case engagement = 4;
case elevage = 5;
case mention = 6;
case charte = 7;
/**
* Optionnal labels definition.
@ -27,7 +25,5 @@ enum GeneralConfigType: int
self::demarche->name => 'Demarche',
self::engagement->name => 'Engagement',
self::elevage->name => 'Elevage',
self::mention->name => 'Mention légales',
self::charte->name => 'Charte',
];
}

View file

@ -0,0 +1,23 @@
<?php
namespace App\Enums;
use App\Traits\Enums\BaseEnum;
enum StaticPageType: int
{
use BaseEnum;
case confidentiality = 1;
case legals = 2;
/**
* Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/
private const LABELS = [
self::confidentiality->name => 'Charte de Confidentialité',
self::legals->name => 'Mentions légales et CGU',
];
}

View file

@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\StaticPages\UpdateStaticPageRequest;
use App\Models\StaticPage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class StaticPageController extends Controller
{
/**
* Create the controller instance.
*/
public function __construct()
{
$this->authorizeResource(StaticPage::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 $query */
$query = StaticPage::query();
/** @var string $search Search field */
$search = $request->search;
if ($search) {
$this->searchQuery(
$query,
$search,
null,
'title',
);
}
$searchFields = \implode(', ', [
trans('validation.attributes.title'),
]);
/** Sort columns with a query */
$this->sortQuery($query);
/** Custom pagination */
$staticPageModelList = $this->paginate($query);
return view('bo.pages.static_pages.index', compact('staticPageModelList', 'search', 'searchFields'));
}
/**
* Show a specific resource.
*
* @param \App\Models\StaticPage $static_page
* @return \Illuminate\Contracts\View\View
*/
public function show(StaticPage $static_page): \Illuminate\Contracts\View\View
{
return view('bo.pages.static_pages.show', ['staticPageModel' => $static_page]);
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\StaticPage $static_page
* @return \Illuminate\Contracts\View\View
*/
public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View
{
return view('bo.pages.static_pages.edit', ['staticPageModel' => $static_page]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Bo\StaticPages\UpdateStaticPageRequest $request
* @param \App\Models\StaticPage $static_page
* @return \Illuminate\Http\RedirectResponse
*/
public function update(UpdateStaticPageRequest $request, StaticPage $static_page): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request, $static_page) {
$static_page->fill($request->validated());
if ($static_page->saveOrFail()) {
return redirect()->route('bo.static_pages.edit', $static_page)
->with('success', __('crud.messages.has_been_updated', [
'model' => Str::ucfirst(\trans_choice('models.classes.static_page', 1))
]));
}
return redirect()->route('bo.static_pages.edit', $static_page)
->with('error', __('crud.messages.cannot_be_updated', [
'model' => Str::ucfirst(\trans_choice('models.classes.static_page', 1))
]));
});
}
}

View file

@ -2,8 +2,10 @@
namespace App\Http\Controllers\Fo;
use App\Enums\StaticPageType;
use App\Http\Controllers\Controller;
use App\Models\GeneralConfig;
use App\Models\StaticPage;
class HomeController extends Controller
{
@ -14,9 +16,11 @@ class HomeController extends Controller
*/
public function index(): \Illuminate\Contracts\View\View
{
$configList = GeneralConfig::all()->keyBy(function (GeneralConfig $item) {
$configList = GeneralConfig::all()->keyBy(function (GeneralConfig $item) {
return $item->type->value();
});
return view('fo.pages.home', compact('configList'));
$legalsStaticPageModel = StaticPage::query()->where('type', StaticPageType::legals)->first();
$confidStaticPageModel = StaticPage::query()->where('type', StaticPageType::confidentiality)->first();
return view('fo.pages.home', compact('configList', 'legalsStaticPageModel', 'confidStaticPageModel'));
}
}

View file

@ -0,0 +1,59 @@
<?php
namespace App\Http\Requests\Bo\StaticPages;
use App\Rules\WysiwygLength;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
class UpdateStaticPageRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::check('update', $this->route('static_page'));
}
/**
* Prepare the data for validation.
*
* @return void
*/
public function prepareForValidation(): void
{
$this->merge([
'content' => Str::of($this->input('content'))->value()
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'title' => 'required|min:3|max:255',
'content' => ['required', 'string', new WysiwygLength(15)],
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'title' => trans('validation.attributes.title'),
'content' => trans('validation.attributes.content'),
];
}
}

143
app/Models/StaticPage.php Normal file
View file

@ -0,0 +1,143 @@
<?php
namespace App\Models;
use App\Enums\StaticPageType;
use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use App\Traits\Models\MiniCrudModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
/**
* @property \App\Enums\StaticPageType $type Page type (StaticPageEnum).
* @property string $title Title for the page.
* @property string $slug Slug of the title for the page.
* @property string $content WYSIWYG text content using ckeditor.
* @property-read \Illuminate\Support\Carbon $created_at Created date.
* @property-read \Illuminate\Support\Carbon $updated_at Updated date.
*/
class StaticPage extends Model
{
use ActivityLog;
use HasFactory;
use MiniCrudModel;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'type',
'title',
'subtitle',
'content',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'type' => StaticPageType::class,
'data' => 'object',
];
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted(): void
{
static::creating(function () {
throw new \RuntimeException("Creating a new page is not authorized");
});
static::updating(function (self $model) {
self::assertTitleIsUnique($model->title, $model->getKey());
$model->slug = Str::slug($model->title);
});
static::updated(function (self $model) {
self::resetCache($model->type);
});
static::deleted(function () {
throw new \RuntimeException('Deleting a page is not authorized');
});
}
// * ROUTABLE
/**
* Get the value of the model's route key.
*
* @return mixed
*/
public function getRouteKey(): mixed
{
/** @var \App\Enums\StaticPageType */
$enum = $this->getAttribute($this->getRouteKeyName());
return $enum->value();
}
/**
* Get the route key for the model.
*
* ! Type is the routable parameter
*
* @return string
*/
public function getRouteKeyName(): string
{
return 'type';
}
// * METHODS
/**
* Asserts using validation that the title is unique
*
* @param string $title
* @param integer|null $id
* @return void
* @throws \Illuminate\Validation\ValidationException If an actu title already exists.
*/
private static function assertTitleIsUnique(string $title, ?int $id = null): void
{
$table = (new self())->getTable();
ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id);
ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($title), $id);
}
/**
* Reset all cache elements related to this model.
*
* @param \App\Enums\StaticPageType $type
* @return void
*/
private static function resetCache(StaticPageType $type): void
{
Cache::forget(sprintf('%sStaticPage', $type->name));
self::getCachedStaticPage($type);
// Breeding pages.
Cache::forget('breedingStaticPages');
}
/**
* Get cached static page associated to a given type.
*
* @param \App\Enums\StaticPageType $type
* @return \App\Models\StaticPage
*/
public static function getCachedStaticPage(StaticPageType $type): \App\Models\StaticPage
{
return Cache::rememberForever(
sprintf('%sStaticPage', $type->name),
fn() => self::query()->where('type', $type)->first()
);
}
}

View file

@ -55,7 +55,6 @@ class User extends Authenticatable
*/
protected $casts = [
'role' => RoleEnum::class,
'email_verified_at' => 'datetime',
'published' => 'boolean',
'published_at' => 'datetime',
];

View file

@ -0,0 +1,47 @@
<?php
namespace App\Policies;
use App\Enums\Users\RoleEnum;
use App\Models\StaticPage;
use App\Models\User;
use App\Policies\Rules\UserStaticRules;
class StaticPagePolicy
{
/**
* 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 update the model.
*
* @param \App\Models\User $authUser
* @param \App\Models\StaticPage $static_page
* @return boolean
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
*/
public function update(User $authUser, StaticPage $static_page): bool
{
// phpcs:enable
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
}

View file

@ -0,0 +1,83 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Str;
/**
* Check the length of a Wysiwyg field, excluding tags and end spaces.
*
* @package App\Rules
*/
class WysiwygLength implements ValidationRule
{
/**
* Construct method.
*
* @param integer $min The minimum length of the content (excluding tags). Default is 15.
* @param integer|null $max The maximum length of the content (excluding tags).
* Default is null (max will be defined by the type of the column in DB).
* @return void
* @throws \InvalidArgumentException If $max < $min.
*/
public function __construct(private int $min = 15, private int|null $max = null)
{
if ($max !== null && $max < $min && $min < 0) {
throw new \InvalidArgumentException(sprintf(
'$max should be higher than $min. $max = %d. $min = %d.',
$max,
$min
));
}
}
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param \Closure $fail
*
* @return void
*/
public function validate(string $attribute, mixed $value, \Closure $fail): void
{
$length = Str::length(\strip_tags($value));
$translatedAttribute = self::getTranslatedAttribute($attribute);
if (!\is_null($this->max) and !($length >= $this->min && $length <= $this->max)) {
$fail(trans('validation.between.string', [
'attribute' => $translatedAttribute,
'min' => $this->min,
'max' => $this->max
]));
return;
}
if ($length < $this->min) {
$fail(trans('validation.min.string', [
'attribute' => $translatedAttribute,
'min' => $this->min
]));
}
}
/**
* Get the correct translation for the given attrribute.
*
* @param string $attribute
* @return string
*/
private static function getTranslatedAttribute(string $attribute): string
{
/** @var \Illuminate\Translation\Translator $trans */
$trans = trans();
if ($trans->has('validation.attributes.' . $attribute)) {
return trans('validation.attributes.' . $attribute);
}
if ($trans->has('validation.custom.' . $attribute)) {
return trans('validation.custom.' . $attribute);
}
return $attribute;
}
}

View file

@ -20,25 +20,10 @@ class UserFactory extends Factory
'first_name' => fake()->firstname(),
'last_name' => fake()->lastname(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'remember_token' => Str::random(10),
'role' => \collect(RoleEnum::toArray())->random()->value,
'published' => $published,
'published_at' => ($published) ? now() : null,
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return static
*/
public function unverified(): static
{
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
return $this->state(fn() => [
'email_verified_at' => null,
]);
}
}

View file

@ -0,0 +1,40 @@
<?php
use App\Models\GeneralConfig;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('static_pages', function (Blueprint $table) {
$table->id();
$table->unsignedTinyInteger('type')->unique()->comment('Type of the page.');
$table->string('title')->comment('Title of the page.');
$table->string('slug')->unique()->comment('Unique slug from the title of the page.');
$table->text('content')->comment('Text content of the page.');
$table->timestamps();
});
// Remove old enum values.
GeneralConfig::query()->whereKey(6)->delete();
GeneralConfig::query()->whereKey(7)->delete();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('static_pages');
}
};

View file

@ -14,7 +14,8 @@ class DatabaseSeeder extends Seeder
public function run()
{
$this->call([
UserSeeder::class
UserSeeder::class,
StaticPageSeeder::class
]);
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace Database\Seeders;
use App\Enums\StaticPageType;
use App\Models\StaticPage;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class StaticPageSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$staticPageModel = new StaticPage();
$staticPageModel->slug = Str::slug(StaticPageType::legals->label());
$staticPageModel->type = StaticPageType::legals;
$staticPageModel->title = StaticPageType::legals->label();
$staticPageModel->content = \clean(\fake()->randomHtml(6, 7));
$staticPageModel->saveQuietly();
$staticPageModel = new StaticPage();
$staticPageModel->slug = Str::slug(StaticPageType::confidentiality->label());
$staticPageModel->type = StaticPageType::confidentiality;
$staticPageModel->title = StaticPageType::confidentiality->label();
$staticPageModel->content = \clean(\fake()->randomHtml(6, 7));
$staticPageModel->saveQuietly();
}
}

View file

@ -25,9 +25,6 @@ return [
'no_results' => 'Aucun résultat pour :model',
'publish' => 'Publié',
'unpublish' => 'Dépublié',
'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).',
],
'libs' => [

View file

@ -5,5 +5,6 @@ return [
'user' => 'utilisateur',
'activity_log' => 'journal d\'activité|journaux d\'activité',
'section' => 'section',
'static_page' => 'page statique|pages statiques',
]
];

View file

@ -214,7 +214,7 @@ return [
'username' => 'nom d\'utilisateur',
'year' => 'année',
],
'custom' => [
'custom' => [
'of_the' => [
'male' => 'du ',
'female' => 'de la ',

View file

@ -1,13 +1,14 @@
@auth('backend')
<ul class="navbar-nav border-top border-lg-0 mt-lg-0 me-auto mt-2">
<li class="nav-item">
<a class="nav-link @if (request()->routeIs('bo.dashboard')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.dashboard') }}"
title="{{ __('Revenir à l\'accueil') }}">
<a class="nav-link @if (request()->routeIs('bo.dashboard')) active @endif" data-bs-toggle="tooltip"
href="{{ route('bo.dashboard') }}" title="{{ __('Revenir à l\'accueil') }}">
{{ __('Accueil') }}
</a>
</li>
<li class="nav-item">
<a class="nav-link @if (request()->routeIs('bo.general_configs.edit') and request()->general_config->type->value == \App\Enums\GeneralConfigType::menu->value) active @endif" data-bs-toggle="tooltip"
<a class="nav-link @if (request()->routeIs('bo.general_configs.edit') and
request()->general_config->type->value == \App\Enums\GeneralConfigType::menu->value) active @endif" data-bs-toggle="tooltip"
href="{{ route('bo.general_configs.edit', ['general_config' => \App\Enums\GeneralConfigType::menu]) }}"
title="{{ __('Administrer :model', ['model' => \App\Enums\GeneralConfigType::menu->label()]) }}">
{{ \App\Enums\GeneralConfigType::menu->label() }}
@ -46,34 +47,31 @@
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle @if (request()->routeIs('bo.general_configs.edit') and
request()->general_config->type->value == \App\Enums\GeneralConfigType::mention->value ||
request()->general_config->type->value == \App\Enums\GeneralConfigType::charte->value) active @endif" id="rgpdDropdown" data-bs-toggle="dropdown"
role="button" aria-expanded="false">
<a class="nav-link dropdown-toggle @if (request()->routeIs('bo.static_pages.edit')) active @endif" id="rgpdDropdown"
data-bs-toggle="dropdown" role="button" aria-expanded="false">
{{ __('RGPD') }}
</a>
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="rgpdDropdown">
<a class="nav-link @if (request()->routeIs('bo.general_configs.edit') and
request()->general_config->type->value == \App\Enums\GeneralConfigType::mention->value) active @endif py-1 text-center" data-bs-toggle="tooltip"
data-bs-placement="right"
href="{{ route('bo.general_configs.edit', ['general_config' => \App\Enums\GeneralConfigType::mention->value]) }}"
title="{{ __('Administrer :model', ['model' => \App\Enums\GeneralConfigType::mention->label()]) }}">
{{ \App\Enums\GeneralConfigType::mention->label() }}
<a class="nav-link @if (request()->routeIs('bo.static_pages.edit') && request()->static_page->type->equals(\App\Enums\StaticPageType::legals)) active @endif py-1 text-center"
data-bs-toggle="tooltip" data-bs-placement="right"
href="{{ route('bo.static_pages.edit', ['static_page' => \App\Enums\StaticPageType::legals->value]) }}"
title="{{ __('Administrer :model', ['model' => \App\Enums\StaticPageType::legals->label()]) }}">
{{ \App\Enums\StaticPageType::legals->label() }}
</a>
<hr class="dropdown-divider">
<a class="nav-link @if (request()->routeIs('bo.general_configs.edit') and request()->general_config->type->value == \App\Enums\GeneralConfigType::charte->value) active @endif py-1 text-center" data-bs-toggle="tooltip"
data-bs-placement="right"
href="{{ route('bo.general_configs.edit', ['general_config' => \App\Enums\GeneralConfigType::charte->value]) }}"
title="{{ __('Administrer :model', ['model' => \App\Enums\GeneralConfigType::charte->label()]) }}">
{{ \App\Enums\GeneralConfigType::charte->label() }}
<a class="nav-link @if (request()->routeIs('bo.static_pages.edit') && request()->static_page->type->equals(\App\Enums\StaticPageType::confidentiality)) active @endif py-1 text-center"
data-bs-toggle="tooltip" data-bs-placement="right"
href="{{ route('bo.static_pages.edit', ['static_page' => \App\Enums\StaticPageType::confidentiality->value]) }}"
title="{{ __('Administrer :model', ['model' => \App\Enums\StaticPageType::confidentiality->label()]) }}">
{{ \App\Enums\StaticPageType::confidentiality->label() }}
</a>
</div>
</li>
@canAny(['isConceptor', 'viewAny'], \App\Models\User::class)
<li class="nav-item">
<div class="dropdown">
<a class="nav-link @if (request()->routeIs('bo.users.*') || request()->routeIs('bo.activity_logs.*')) active @endif dropdown-toggle" data-bs-toggle="dropdown" type="button"
aria-expanded="false">
<a class="nav-link @if (request()->routeIs('bo.users.*') || request()->routeIs('bo.activity_logs.*')) active @endif dropdown-toggle"
data-bs-toggle="dropdown" type="button" aria-expanded="false">
{{ __('Avancé') }}
</a>
<ol class="dropdown-menu">

View file

@ -0,0 +1,45 @@
@extends('bo.layout', ['brParam' => $staticPageModel])
@section('title', __('Édition d\'une :model', ['model' => trans_choice('models.classes.static_page', 1)]))
@section('description', __('Édition d\'une :model déjà existante', ['model' => trans_choice('models.classes.static_page', 1)]))
@section('breadcrumb', request()->route()->getName())
@section('content')
<div class="row pb-3">
<div class="col-12 d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
<div class="d-flex align-items-start flex-row">
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $staticPageModel])
</div>
<div class="mb-md-0 mb-2">
<div class="btn-group">
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="submit"
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.static_page')]) }}">
{{ Str::ucfirst(__('crud.actions.save')) }}
</button>
</div>
</div>
</div>
<div class="col-12 overflow-hidden mt-3">
<div class="bg-body-tertiary rounded-3 p-3">
<p class="m-0">
{{ str(__('validation.attributes.updated_at'))->ucFirst() }}
<span class="fw-bold">{{ $staticPageModel->updated_at->isoFormat('LLLL') }}</span>
</p>
</div>
</div>
</div>
<form action="{{ route('bo.static_pages.update', $staticPageModel) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
@include('bo.pages.static_pages.form')
@include('bo.partials.script-button-clone')
<div class="row">
<div class="col text-center">
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.static_page')]) }}">
{{ str(__('crud.actions.save'))->ucfirst() }}
</button>
</div>
</div>
</form>
@endsection

View file

@ -0,0 +1,51 @@
<div class="row">
{{-- TITLE --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ str(__('validation.attributes.title'))->ucfirst() }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar', [
'id' => 'userFirstname',
'label' => __('Titre de la :model', ['model' => trans_choice('models.classes.static_page', 1)]),
'hasWordCounter' => true,
'name' => 'title',
'required' => true,
'model' => $staticPageModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __('titre de la :model', ['model' => trans_choice('models.classes.static_page', 1)]),
'min' => 3,
'max' => 255,
]),
'placeholder' => __('Un titre clair et concis'),
])
</div>
</div>
</fieldset>
</div>
{{-- CONTENT --}}
<div class="col-12 mb-3">
<fieldset class="border p-3">
<legend>{{ str(__('validation.attributes.content'))->ucfirst() }}</legend>
<div class="row mb-3">
<div class="col-12">
@include('bo.partials.inputs.text-html', [
'id' => 'articleContent',
'label' => __(':field :inter:model', [
'field' => str(__('validation.attributes.content'))->ucfirst(),
'inter' => __('validation.custom.of_the.female'),
'model' => trans_choice('models.classes.static_page', 1),
]),
'name' => 'content',
'model' => $staticPageModel ?? null,
'required' => true,
'helper' => __('crud.minicrud.text_warning'),
])
</div>
</div>
</fieldset>
</div>
<div class="col-12 text-center">
<p><b>{{ __('* Champs obligatoires') }}</b></p>
</div>
</div>

View file

@ -1,34 +1,6 @@
@php
$configCharte = $configList->get(App\Enums\GeneralConfigType::charte->value());
@endphp
<template id="popin-politique">
<swal-html>
<h2 class="title text-brown mb1">{{ $configCharte->data['charte_title']['value'] }}</h2>
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_1']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_1']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_2']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_2']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_3']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_3']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_4']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_4']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_5']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_5']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_6']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_6']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_7']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_7']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_8']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_8']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_9']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_9']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_10']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_10']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_11']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_11']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_12']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_12']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configCharte->data['charte_subtitle_13']['value'] }}</h3>
{!! clean($configCharte->data['charte_text_13']['value']) !!}
<h3>{{ $confidStaticPageModel->title }}</h3>
{!! clean($confidStaticPageModel->content) !!}
</swal-html>
</template>

View file

@ -1,20 +1,6 @@
@php
$configMention = $configList->get(App\Enums\GeneralConfigType::mention->value());
@endphp
<template id="popin-mention">
<swal-html>
<h2 class="title text-brown mb1">{{ $configMention->data['mention_title']['value'] }}</h2>
<h3 class="subtitle text-yellow ck-content">{{ $configMention->data['mention_subtitle_1']['value'] }}</h3>
{!! clean($configMention->data['mention_text_1']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configMention->data['mention_subtitle_2']['value'] }}</h3>
{!! clean($configMention->data['mention_text_2']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configMention->data['mention_subtitle_3']['value'] }}</h3>
{!! clean($configMention->data['mention_text_3']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configMention->data['mention_subtitle_4']['value'] }}</h3>
{!! clean($configMention->data['mention_text_4']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configMention->data['mention_subtitle_5']['value'] }}</h3>
{!! clean($configMention->data['mention_text_5']['value']) !!}
<h3 class="subtitle text-yellow ck-content">{{ $configMention->data['mention_subtitle_6']['value'] }}</h3>
{!! clean($configMention->data['mention_text_6']['value']) !!}
<h3>{{ $legalsStaticPageModel->title }}</h3>
{!! clean($legalsStaticPageModel->content) !!}
</swal-html>
</template>

View file

@ -2,6 +2,7 @@
use App\Models\ActivityLog;
use App\Models\GeneralConfig;
use App\Models\StaticPage;
use App\Models\User;
use Diglactic\Breadcrumbs\Breadcrumbs;
use Diglactic\Breadcrumbs\Generator;
@ -43,3 +44,19 @@ Breadcrumbs::for('bo.activity_logs.show', function (Generator $trail, ActivityLo
$trail->parent('bo.activity_logs.index');
$trail->push(Str::ucfirst(trans('crud.actions.view')), route('bo.activity_logs.show', $activityLogModel));
});
// * STATIC PAGES
Breadcrumbs::for('bo.static_pages.index', function (Generator $trail) {
$trail->push(
Str::of(trans_choice('models.classes.static_page', 2))->ucfirst(),
);
});
Breadcrumbs::for('bo.static_pages.show', function (Generator $trail, StaticPage $static_page) {
$trail->parent('bo.static_pages.index');
$trail->push(Str::ucfirst(trans('crud.actions.show')), route('bo.static_pages.show', $static_page));
});
Breadcrumbs::for('bo.static_pages.edit', function (Generator $trail, StaticPage $static_page) {
$trail->parent('bo.static_pages.index');
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.static_pages.edit', $static_page));
});

View file

@ -4,6 +4,7 @@ use App\Http\Controllers\Bo\ActivityLogController;
use App\Http\Controllers\Bo\DashboardController;
use App\Http\Controllers\Bo\GeneralConfigController;
use App\Http\Controllers\Bo\UserController;
use App\Http\Controllers\Bo\StaticPageController;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
@ -49,6 +50,19 @@ Route::prefix('bo')
'duplicate'
])->name('users.duplicate');
// * StaticPages
Route::resource('pages', StaticPageController::class)
->names([
'index' => 'static_pages.index',
'show' => 'static_pages.show',
'edit' => 'static_pages.edit',
'update' => 'static_pages.update',
])->parameters(['pages' => 'static_page'])
->only(['index', 'show', 'edit', 'update'])
->withoutMiddleware('htmlsanitize')
->middleware(['htmlsanitize:content']);
Route::middleware('can:isConceptor')->group(function () {
// * ACTIVITY LOGS.
Route::resource('activity_logs', ActivityLogController::class)->only(['index', 'show']);