link
This commit is contained in:
parent
324abfc92b
commit
4fcb5e7f4d
4 changed files with 131 additions and 6 deletions
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Sections\PageSectionEnum;
|
||||
use App\Models\Section;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Collection::macro('insertAfter', function ($target, $value, $new_key = null) {
|
||||
if (is_int($target)) {
|
||||
$this->items = array_merge(array_slice($this->items, 0, $target + 1), [$value], array_slice($this->items, $target + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->items as $key => $old) {
|
||||
$new[$key] = $old;
|
||||
if ($key === $target && is_null($new_key)) {
|
||||
$new[] = $value;
|
||||
} elseif ($key === $target) {
|
||||
$new[$new_key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->items = $new;
|
||||
});
|
||||
|
||||
$export = Section::query()->where('section', PageSectionEnum::produce_export)->first();
|
||||
if ($export) {
|
||||
$partsAmount = 3;
|
||||
$data = collect($export->data);
|
||||
for ($i = 1; $i <= $partsAmount; $i++) {
|
||||
$bloc = collect(Section::emptyLinkBloc(
|
||||
[],
|
||||
'',
|
||||
false,
|
||||
"Lien de l'image {$i} de la partie"
|
||||
))->first();
|
||||
$data->insertAfter(
|
||||
"bloc_image{$i}_de_la_partie",
|
||||
$bloc,
|
||||
"bloc_lien_de_limage{$i}_de_la_partie"
|
||||
);
|
||||
}
|
||||
$export->data = $data->all();
|
||||
$export->saveQuietly();
|
||||
}
|
||||
$rhd = Section::query()->where('section', PageSectionEnum::produce_rhd)->first();
|
||||
if ($rhd) {
|
||||
$getEmptyLinkBlock = fn ($i, $k) => collect(Section::emptyLinkBloc(
|
||||
[],
|
||||
'',
|
||||
false,
|
||||
"Lien de l'image {$i} de la partie {$k}"
|
||||
))->first();
|
||||
|
||||
$data = collect($rhd->data);
|
||||
$data->insertAfter(
|
||||
'bloc_image1_de_la_partie1',
|
||||
$getEmptyLinkBlock(1, 1),
|
||||
'bloc_lien_de_limage1_de_la_partie1'
|
||||
);
|
||||
$data->insertAfter(
|
||||
'bloc_image2_de_la_partie1',
|
||||
$getEmptyLinkBlock(2, 1),
|
||||
'bloc_lien_de_limage2_de_la_partie1'
|
||||
);
|
||||
$data->insertAfter(
|
||||
'bloc_image3_de_la_partie1',
|
||||
$getEmptyLinkBlock(3, 1),
|
||||
'bloc_lien_de_limage3_de_la_partie1'
|
||||
);
|
||||
$data->insertAfter(
|
||||
'bloc_image1_de_la_partie2',
|
||||
$getEmptyLinkBlock(1, 2),
|
||||
'bloc_lien_de_limage1_de_la_partie2'
|
||||
);
|
||||
$rhd->data = $data->all();
|
||||
$rhd->saveQuietly();
|
||||
} //end if
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$export = Section::query()->where('section', PageSectionEnum::produce_export)->first();
|
||||
if ($export) {
|
||||
$partsAmount = 3;
|
||||
$data = collect($export->data);
|
||||
for ($i = 1; $i <= $partsAmount; $i++) {
|
||||
$data->forget("bloc_lien_de_limage{$i}_de_la_partie");
|
||||
}
|
||||
$export->data = $data->all();
|
||||
$export->saveQuietly();
|
||||
}
|
||||
$rhd = Section::query()->where('section', PageSectionEnum::produce_rhd)->first();
|
||||
if ($rhd) {
|
||||
$data = collect($rhd->data);
|
||||
$data->forget('bloc_lien_de_limage1_de_la_partie1');
|
||||
$data->forget('bloc_lien_de_limage2_de_la_partie1');
|
||||
$data->forget('bloc_lien_de_limage3_de_la_partie1');
|
||||
$data->forget('bloc_lien_de_limage1_de_la_partie2');
|
||||
$rhd->data = $data->all();
|
||||
$rhd->saveQuietly();
|
||||
} //end if
|
||||
}
|
||||
};
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="col-md-8">
|
||||
@for ($i = 1; $i <= $itemMax; $i++)
|
||||
@include('fo.pages.produce.flex-row', [
|
||||
'image_link' => $data["bloc_lien_de_limage{$i}_{$partName}"]['value'] ?? null,
|
||||
'image' => $data["bloc_image{$i}_{$partName}"]['value'],
|
||||
'alt' => $data["bloc_image{$i}_{$partName}"]['alt'],
|
||||
'title' => $data["bloc_image{$i}_{$partName}"]['title'],
|
||||
|
|
|
|||
|
|
@ -2,7 +2,13 @@
|
|||
'd-flex flex-column flex-sm-row justify-content-center align-items-center my-3',
|
||||
'flex-sm-row-reverse' => $switch,
|
||||
])>
|
||||
<img src="{{ asset($image) }}" title="{{ $title }}" alt="{{ $alt }}" role="img" aria-label="{{ $alt }}">
|
||||
@if (!empty($image_link))
|
||||
<a href="{{ $image_link }}" title="{{ __('Lien de :title', ['title' => $title]) }}" target="_blank">
|
||||
@endisset
|
||||
<img src="{{ asset($image) }}" title="{{ $title }}" alt="{{ $alt }}" role="img" aria-label="{{ $alt }}">
|
||||
@isset($image_link)
|
||||
</a>
|
||||
@endif
|
||||
<div class="d-flex justify-content-start align-items-center mx-3">
|
||||
<div class="text-start">
|
||||
<div class="ck-content">{!! clean($text) !!}</div>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<section class="anchor-padding container my-4 text-center" id="local">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2 class="h2 fw-bold text-primary">{{ $localSection->h2_title }}</h2>
|
||||
<h2 class="fw-bold text-primary mb-3">{{ $localSection->h2_title }}</h2>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="ck-content">{!! clean($localSection->text) !!}</div>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<section class="border-top-curved-tertiary-light">
|
||||
<div class="bg-tertiary-light overflow-hidden pb-5">
|
||||
<div class="container text-center">
|
||||
<h2 class="h2 fw-bold text-primary">{{ $gmsSection->h2_title }}</h2>
|
||||
<h2 class="fw-bold text-primary mb-3">{{ $gmsSection->h2_title }}</h2>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8 mb-3">
|
||||
<div class="ck-content">
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
<section class="border-top-curved-upper-tertiary-light">
|
||||
<div class="overflow-hidden bg-white pb-5">
|
||||
<div class="container text-center">
|
||||
<h2 class="h2 fw-bold text-primary">{{ $rhdSection->h2_title }}</h2>
|
||||
<h2 class="fw-bold text-primary mb-3">{{ $rhdSection->h2_title }}</h2>
|
||||
<div class="row justify-content-center">
|
||||
{{-- PART 1 --}}
|
||||
@include('fo.pages.produce.banner-elements', [
|
||||
|
|
@ -121,7 +121,7 @@
|
|||
<section class="border-top-curved-primary">
|
||||
<div class="bg-primary overflow-hidden pb-5 text-white">
|
||||
<div class="container text-center">
|
||||
<h2 class="h2 fw-bold">{{ $exportSection->h2_title }}</h2>
|
||||
<h2 class="fw-bold mb-3">{{ $exportSection->h2_title }}</h2>
|
||||
<div class="row justify-content-center">
|
||||
@include('fo.pages.produce.banner-elements', [
|
||||
'partName' => 'de_la_partie',
|
||||
|
|
@ -138,7 +138,7 @@
|
|||
<div class="container">
|
||||
<div class="row justify-content-center gx-5">
|
||||
<div class="col-md-8 mb-3 text-center">
|
||||
<h2 class="h2 fw-bold">{{ $qualitySection->h2_title }}</h2>
|
||||
<h2 class="fw-bold mb-3">{{ $qualitySection->h2_title }}</h2>
|
||||
<div class="ck-content">{!! clean($qualitySection->text) !!}</div>
|
||||
@if ($qualitySection->data['bloc_button__on_vous_explique_comment_lire_cetteetiquette']['value'])
|
||||
<a class="btn btn-primary rounded-pill mt-3" href="https://www.etiquettebienetreanimal.fr/"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue