Added seo title and description to ranges
This commit is contained in:
parent
24e89b51ad
commit
7831ff3bee
8 changed files with 125 additions and 6 deletions
|
|
@ -13,7 +13,6 @@ enum StaticPageType: int
|
|||
case confidentiality = 3;
|
||||
case home = 4;
|
||||
case ranges = 5;
|
||||
case range = 6;
|
||||
case klub = 7;
|
||||
case klub_register = 8;
|
||||
case history = 9;
|
||||
|
|
@ -29,7 +28,6 @@ enum StaticPageType: int
|
|||
self::confidentiality->name => 'Confidentialité',
|
||||
self::home->name => 'Accueil',
|
||||
self::ranges->name => 'Nos gammes',
|
||||
self::range->name => 'Une gamme',
|
||||
self::klub->name => 'Le Klub',
|
||||
self::klub_register->name => 'Le Klub - Inscription',
|
||||
self::history->name => 'Notre Histoire',
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ class RangeController extends Controller
|
|||
->where('published', true)
|
||||
->orderBy('order', 'asc')
|
||||
->paginate(9);
|
||||
$staticPageModel = StaticPage::query()->where('type', StaticPageType::range)->first();
|
||||
$newsModels = News::query()
|
||||
->where('published', true)
|
||||
->orderBy('created_at', 'desc')
|
||||
|
|
@ -49,7 +48,6 @@ class RangeController extends Controller
|
|||
'rangeModel',
|
||||
'rangeModels',
|
||||
'productModels',
|
||||
'staticPageModel',
|
||||
'newsModels'
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ class StoreRangeRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'seo_title' => 'required|between:45,70',
|
||||
'seo_description' => 'required|between:50,160',
|
||||
'label' => 'required|string|between:3,255',
|
||||
'picture_alt' => 'required|string|between:3,255',
|
||||
'picture_title' => 'required|string|between:3,255',
|
||||
|
|
@ -71,6 +73,8 @@ class StoreRangeRequest extends FormRequest
|
|||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'seo_title' => trans('validation.custom.seo_title'),
|
||||
'seo_description' => trans('validation.custom.seo_description'),
|
||||
'label' => trans('validation.custom.label'),
|
||||
'picture_alt' => trans('validation.custom.attribute_alt'),
|
||||
'picture_title' => trans('validation.attributes.attribute_title'),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property string $seo_title Utilisé pour la balise title de la page.
|
||||
* @property string $seo_description Utilisé pour la balise meta description
|
||||
* @property string $label Label de la gamme.
|
||||
* @property string $slug Slug à partir du label de la gamme.
|
||||
* @property string $picture Path de l'image de la gamme (579px * 579px).
|
||||
|
|
@ -46,6 +48,8 @@ class Range extends Model
|
|||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'label',
|
||||
'picture',
|
||||
'picture_alt',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class RangeFactory extends Factory
|
|||
{
|
||||
$label = fake()->text(15);
|
||||
return [
|
||||
'seo_title' => fake()->sentence(),
|
||||
'seo_description' => fake()->sentence(),
|
||||
'label' => $label,
|
||||
'slug' => Str::slug($label),
|
||||
'picture_alt' => fake()->sentence(),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$ranges = DB::table('ranges')->get();
|
||||
Schema::table('ranges', function (Blueprint $table) {
|
||||
$table->string('seo_title')->after('id')
|
||||
->comment('Utilisé pour la balise title de la page de gamme');
|
||||
$table->string('seo_description')->after('seo_title')
|
||||
->comment('Utilisé pour la balise meta description de la page de gamme');
|
||||
});
|
||||
$ranges->each(function (object $range) {
|
||||
DB::table('ranges')->where('id', $range->id)
|
||||
->update([
|
||||
'seo_title' => $range->label,
|
||||
'seo_description' => $range->label,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ranges', function (Blueprint $table) {
|
||||
$table->dropColumn('seo_title');
|
||||
$table->dropColumn('seo_description');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -1,4 +1,76 @@
|
|||
<div class="row">
|
||||
{{-- SEO --}}
|
||||
<div class="col-12 pb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.custom.seo')) }}</legend>
|
||||
<div class="row mb-3">
|
||||
{{-- SEO_TITLE --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'rangeSeoTitle',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_title')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.range'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'seo_title',
|
||||
'required' => true,
|
||||
'model' => $rangeModel ?? null,
|
||||
'helper' => sprintf(
|
||||
'%s %s',
|
||||
__('crud.helpers.seo_title'),
|
||||
__('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.custom.seo_title'),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => __('models.classes.range'),
|
||||
]),
|
||||
'min' => 45,
|
||||
'max' => 70,
|
||||
])),
|
||||
'placeholder' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_title')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.range'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
{{-- SEO_DESCRIPTION --}}
|
||||
<div class="col-12 col-md-6 m-md-0 mb-3">
|
||||
@include('bo.partials.inputs.varchar-multiline', [
|
||||
'id' => 'rangeSeoDescription',
|
||||
'label' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_description')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.range'),
|
||||
]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'seo_description',
|
||||
'required' => true,
|
||||
'model' => $rangeModel ?? null,
|
||||
'helper' => sprintf(
|
||||
'%s %s',
|
||||
__('crud.helpers.seo_description'),
|
||||
__('validation.between.string', [
|
||||
'attribute' => __(':field :inter:model', [
|
||||
'field' => __('validation.custom.seo_description'),
|
||||
'inter' => __('validation.custom.of_the.female'),
|
||||
'model' => __('models.classes.range'),
|
||||
]),
|
||||
'min' => 50,
|
||||
'max' => 160,
|
||||
])),
|
||||
'placeholder' => __(':field :inter:model', [
|
||||
'field' => Str::ucfirst(__('validation.custom.seo_description')),
|
||||
'inter' => __('validation.custom.of_the.male'),
|
||||
'model' => __('models.classes.range'),
|
||||
]),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- LABEL --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border p-3">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@extends('fo.layout')
|
||||
|
||||
@section('title', __($staticPageModel->seo_title))
|
||||
@section('description', __($staticPageModel->seo_description))
|
||||
@section('title', __($rangeModel->seo_title))
|
||||
@section('description', __($rangeModel->seo_description))
|
||||
@section('breadcrumb',
|
||||
request()->route()->getName())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue