Merge branch 'ts-1857' into 'develop'
added language management for sliders See merge request ldc-web/projets/nature-and-respect!42
This commit is contained in:
commit
4a145cd8f4
11 changed files with 104 additions and 21 deletions
|
|
@ -15,8 +15,13 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$home = Home::query()->firstOrFail();
|
||||
$sliders = Slider::query()->where('status', true)->orderBy('order')->get();
|
||||
$currentLocale = app()->currentLocale();
|
||||
$home = Home::query()->firstOrFail();
|
||||
$sliders = Slider::query()
|
||||
->where('status', true)
|
||||
->orderBy('order')
|
||||
->whereJsonContains('locales', $currentLocale)
|
||||
->get();
|
||||
return view('fo.pages.home', compact('home', 'sliders'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class StoreSliderRequest extends FormRequest
|
|||
'status' => $this->status ? true : false,
|
||||
'publish_at' => $this->publish_at ? \str_replace('T', ' ', $this->publish_at) : null,
|
||||
'unpublish_at' => $this->unpublish_at ? \str_replace('T', ' ', $this->unpublish_at) : null,
|
||||
'locales' => \collect($this->locales)->filter()->unique()->all()
|
||||
]);
|
||||
$this->mergePicture('picture');
|
||||
}
|
||||
|
|
@ -62,6 +63,8 @@ class StoreSliderRequest extends FormRequest
|
|||
'picture_alt' => 'required|min:3|max:255',
|
||||
'picture_title' => 'required|min:3|max:255',
|
||||
'status' => 'required|boolean',
|
||||
'locales' => 'required|array',
|
||||
'locales.*' => ['required', \sprintf('in:%s', \implode(',', \config('app.locales')))],
|
||||
'publish_at' => 'sometimes|nullable|date',
|
||||
'unpublish_at' => 'sometimes|nullable|date'
|
||||
];
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class Slider extends Model
|
|||
'picture_title',
|
||||
'status',
|
||||
'order',
|
||||
'locales',
|
||||
'unpublish_at',
|
||||
'publish_at',
|
||||
'created_at',
|
||||
|
|
@ -77,7 +78,8 @@ class Slider extends Model
|
|||
'type' => TypeEnum::class,
|
||||
'status' => 'bool',
|
||||
'publish_at' => 'datetime',
|
||||
'unpublish_at' => 'datetime'
|
||||
'unpublish_at' => 'datetime',
|
||||
'locales' => 'array',
|
||||
];
|
||||
|
||||
// * EVENTS
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ final class SliderFactory extends Factory
|
|||
{
|
||||
$linkBoolean = fake()->boolean(75);
|
||||
$statusBoolean = fake()->boolean(75);
|
||||
$locales = \collect(\config('app.locales'))->shuffle();
|
||||
$locales->shift();
|
||||
return [
|
||||
'type' => \collect(TypeEnum::cases())->random(),
|
||||
'title' => fake()->unique()->word,
|
||||
|
|
@ -40,6 +42,7 @@ final class SliderFactory extends Factory
|
|||
'status' => $statusBoolean,
|
||||
'unpublish_at' => null,
|
||||
'publish_at' => ($statusBoolean) ? fake()->dateTime() : null,
|
||||
'locales' => $locales
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
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::table('sliders', function (Blueprint $table) {
|
||||
$table->json('locales')
|
||||
->after('order')
|
||||
->comment('Langue du slider');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('sliders', function (Blueprint $table) {
|
||||
$table->dropColumn('locales');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -20,7 +20,7 @@ class SliderSeeder extends Seeder
|
|||
$slider->picture = FileStorageHelper::storeFile($slider, new \SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/sliders/default-picture-1270x930.png'
|
||||
)));
|
||||
$slider->order = $jj;
|
||||
$slider->order = $jj;
|
||||
$slider->saveOrFail();
|
||||
$jj = $jj + 1;
|
||||
});
|
||||
|
|
|
|||
10
package-lock.json
generated
10
package-lock.json
generated
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "wenn-dann-mit-respekt",
|
||||
"name": "srcs",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"@fortawesome/free-regular-svg-icons": "^6.1.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.1.2",
|
||||
"@fortawesome/vue-fontawesome": "^3.0.1",
|
||||
"@ldc-web/cookie-notice": "^3.0.3",
|
||||
"@ldc-web/cookie-notice": "^3.1.2",
|
||||
"@rushstack/eslint-patch": "^1.1.4",
|
||||
"@sipec/vue3-tags-input": "^3.0.4",
|
||||
"@splidejs/splide": "^4.1.4",
|
||||
|
|
@ -2435,9 +2435,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/@ldc-web/cookie-notice": {
|
||||
"version": "3.0.8",
|
||||
"resolved": "https://lab.s-web.fr/api/v4/projects/50/packages/npm/@ldc-web/cookie-notice/-/@ldc-web/cookie-notice-3.0.8.tgz",
|
||||
"integrity": "sha1-FOc6hEv1L9NOnRDOdyBnbIsd31A=",
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://lab.s-web.fr/api/v4/projects/50/packages/npm/@ldc-web/cookie-notice/-/@ldc-web/cookie-notice-3.1.2.tgz",
|
||||
"integrity": "sha1-UNRi9oPfcnrw4lfGSh4wDUqqcIU=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@nodelib/fs.scandir": {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"@fortawesome/free-regular-svg-icons": "^6.1.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.1.2",
|
||||
"@fortawesome/vue-fontawesome": "^3.0.1",
|
||||
"@ldc-web/cookie-notice": "^3.0.3",
|
||||
"@ldc-web/cookie-notice": "^3.1.2",
|
||||
"@rushstack/eslint-patch": "^1.1.4",
|
||||
"@sipec/vue3-tags-input": "^3.0.4",
|
||||
"@splidejs/splide": "^4.1.4",
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@
|
|||
"Ingredients": "Zutaten",
|
||||
"Introduction": "Einführung",
|
||||
"Last name": "Nachname",
|
||||
"Languages in which to display the News": "Sprachen, in denen der News angezeigt werden soll",
|
||||
"Languages in which to display the Slider": "Sprachen, in denen der Slider angezeigt werden soll",
|
||||
"LDC Sablé collects the following categories of personal data": "LDC Sablé erhebt die folgenden Kategorien personenbezogener Daten",
|
||||
"LDC Sablé has used its best efforts to ensure the accuracy of the information on its website (hereinafter the website). However, LDC Sablé is not responsible for the accuracy, errors or omissions on the Website. The use of this information is the sole responsibility of the user.": "LDC Sablé hat sich nach besten Kräften bemüht, die Richtigkeit der Informationen auf seiner Website (im Folgenden die Website) zu gewährleisten. LDC Sablé ist jedoch nicht verantwortlich für die Richtigkeit, Fehler oder Auslassungen auf der Website. Für die Verwendung dieser Informationen ist allein der Benutzer verantwortlich.",
|
||||
"LDC Sablé makes no warranty, express or implied, and assumes no liability arising out of access to or use of this site, including any degradation or viruses that may infect the user's computer equipment or other property.": "LDC Sablé gibt keine ausdrückliche oder stillschweigende Garantie und übernimmt keine Haftung, die sich aus dem Zugriff oder der Nutzung dieser Site ergeben könnte, einschließlich jeglicher Verschlechterung oder Viren, die Computerausrüstung oder anderes Eigentum des Benutzers infizieren könnten.",
|
||||
|
|
@ -157,6 +159,9 @@
|
|||
"Right to restrict processing": "Recht auf einschränkung der verarbeitung",
|
||||
"rules": "regeln",
|
||||
"save": "sparen",
|
||||
"Search a specific language": "Suche in einer bestimmten Sprache",
|
||||
"Select language(s) among this list in which the news should display (minimum 1, maximum :max)": "Wählen Sie aus dieser Liste die Sprache(n) aus, in der die Nachrichten angezeigt werden sollen (mindestens 1, höchstens :max)",
|
||||
"Select language(s) among this list in which the Slider should display (minimum 1, maximum :max)": "Wählen Sie aus dieser Liste die Sprache(n) aus, in der der Slider angezeigt werden soll (Minimum 1, Maximum :max)",
|
||||
"Send Password Reset Link": "Link zum Zurücksetzen des Passworts senden",
|
||||
"Send": "Versenden",
|
||||
"Server Error": "Interner Fehler",
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@
|
|||
{{-- LOCALES --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Languages in which to display the news') }}</legend>
|
||||
<legend>{{ __('Languages in which to display the News') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@php
|
||||
|
|
@ -173,13 +173,13 @@
|
|||
@endphp
|
||||
@include('bo.partials.inputs.select-multiple-enum', [
|
||||
'id' => 'newsLocales',
|
||||
'label' => __('Locales in which to display the news'),
|
||||
'label' => __('Languages in which to display the News'),
|
||||
'name' => 'locales',
|
||||
'itemsSelected' => $selectedItemList,
|
||||
'itemsList' => $itemsList,
|
||||
'itemLimit' => [0, count($itemsList)],
|
||||
'placeholder' => __('Search a specific Locales'),
|
||||
'helper' => __('Select Locales(s) among this list in which the news should display (minimum 1, maximum :max)', [
|
||||
'placeholder' => __('Search a specific language'),
|
||||
'helper' => __('Select language(s) among this list in which the news should display (minimum 1, maximum :max)', [
|
||||
'max' => count($itemsList)
|
||||
]),
|
||||
'required' => true,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.tinyint-enum', [
|
||||
'id' => 'recipesType',
|
||||
'id' => 'sliderType',
|
||||
'label' => __('crud.minicrud.associated_enum', ['enum' => 'type']),
|
||||
'name' => 'type',
|
||||
'model' => $sliderModel ?? null,
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
'required' => true,
|
||||
'model' => $sliderModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __('Title of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'attribute' => __('Title of the :model', ['model' => Str::singular(__('models.classes.sliders'))]),
|
||||
'min' => 3,
|
||||
'max' => 255
|
||||
]),
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
'required' => true,
|
||||
'model' => $sliderModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __('Subtitle of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'attribute' => __('Subtitle of the :model', ['model' => Str::singular(__('models.classes.sliders'))]),
|
||||
'min' => 3,
|
||||
'max' => 255
|
||||
]),
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'sliderPictureAlt',
|
||||
'label' => __('Alt attribute of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'label' => __('Alt attribute of the :model', ['model' => Str::singular(__('models.classes.sliders'))]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_alt',
|
||||
'required' => true,
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'sliderPictureTitle',
|
||||
'label' => __('Title attribute of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'label' => __('Title attribute of the :model', ['model' => Str::singular(__('models.classes.sliders'))]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'picture_title',
|
||||
'required' => true,
|
||||
|
|
@ -148,7 +148,7 @@
|
|||
'required' => true,
|
||||
'model' => $sliderModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __('Link of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'attribute' => __('Link of the :model', ['model' => Str::singular(__('models.classes.sliders'))]),
|
||||
'min' => 3,
|
||||
'max' => 255
|
||||
]),
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
'required' => true,
|
||||
'model' => $sliderModel ?? null,
|
||||
'helper' => __('validation.between.string', [
|
||||
'attribute' => __('Title of the link of the :model', ['model' => Str::singular(__('models.classes.products'))]),
|
||||
'attribute' => __('Title of the link of the :model', ['model' => Str::singular(__('models.classes.sliders'))]),
|
||||
'min' => 3,
|
||||
'max' => 255
|
||||
]),
|
||||
|
|
@ -228,4 +228,35 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- LOCALES --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Languages in which to display the Slider') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@php
|
||||
$itemsList = collect(config('app.locales'))->map(fn($locale) => (object)[
|
||||
'label' => $locale, 'value' => $locale,
|
||||
]);
|
||||
$values = collect(old('locales', $sliderModel->locales ?? []))->values();
|
||||
$selectedItemList = collect($itemsList)->filter(fn($locale) =>
|
||||
$values->filter(fn($value) => $value === $locale->value)->count())->values();
|
||||
@endphp
|
||||
@include('bo.partials.inputs.select-multiple-enum', [
|
||||
'id' => 'sliderLocales',
|
||||
'label' => __('Languages in which to display the Slider'),
|
||||
'name' => 'locales',
|
||||
'itemsSelected' => $selectedItemList,
|
||||
'itemsList' => $itemsList,
|
||||
'itemLimit' => [0, count($itemsList)],
|
||||
'placeholder' => __('Search a specific language'),
|
||||
'helper' => __('Select language(s) among this list in which the Slider should display (minimum 1, maximum :max)', [
|
||||
'max' => count($itemsList)
|
||||
]),
|
||||
'required' => true,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue