diff --git a/app/Http/Controllers/Bo/CarouselController.php b/app/Http/Controllers/Bo/CarouselController.php new file mode 100644 index 0000000..90c8d98 --- /dev/null +++ b/app/Http/Controllers/Bo/CarouselController.php @@ -0,0 +1,222 @@ +authorizeResource(Carousel::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 $carouselModels */ + $carouselModels = Carousel::query()->with('section'); + $sectionModels = Section::query()->whereHas('carousels')->get(); + + $selectedSection = intval($request->section); + + $carouselModels = $carouselModels->when($selectedSection, function ($query) use ($selectedSection) { + $query->where('section_id', $selectedSection); + }); + + /** @var string $search Search field */ + $search = $request->input('search'); + if ($search) { + $this->searchQuery( + $carouselModels, + $search, + null, + 'title', + ); + } + $searchFields = \implode(', ', [ + Str::ucFirst(trans('validation.attributes.title')), + ]); + + /** Sort columns with a query */ + $this->sortQuery($carouselModels); + + /** Custom pagination */ + $carouselModels = $this->paginate($carouselModels); + + return view('bo.pages.carousels.index', compact( + 'carouselModels', + 'sectionModels', + 'selectedSection', + 'search', + 'searchFields' + )); + } + + + /** + * Show the form for creating a new resource. + * + * @param \App\Models\Carousel $carousel + * @return \Illuminate\Contracts\View\View + */ + public function create(Carousel $carousel): \Illuminate\Contracts\View\View + { + $sectionModels = Section::all(); + + return view('bo.pages.carousels.create', [ + 'carouselModel' => $carousel, + 'sectionModels' => $sectionModels + ]); + } + + /** + * Store a newly created resource in storage. + * + * @param \App\Http\Requests\Bo\Carousels\StoreCarouselRequest $request + * @return \Illuminate\Http\RedirectResponse + */ + public function store(StoreCarouselRequest $request): \Illuminate\Http\RedirectResponse + { + return DB::transaction(function () use ($request) { + $carousel = new Carousel(); + $carousel->fill($request->validated()); + + if (!Arr::exists($request->validated(), 'media')) { + $carousel->media = []; + } + + // Set the new pictures files in the pictures array. + collect($request->only(['media.pictures.*.path'])) + ->each( + function (mixed $value, string $attribute) use ($carousel) { + foreach ($value['pictures']['*']['path'] as $index => $file) { + if ($file instanceof \Illuminate\Http\UploadedFile) { + $carousel->setAttribute( + "{$attribute}->pictures->{$index}->path", + FileStorageHelper::storeFile($carousel, $file, true) + ); + } + } + } + ); + + if ($carousel->saveOrFail()) { + return redirect()->route('bo.carousels.edit', $carousel) + ->with('success', trans('crud.messages.has_been_created', [ + 'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1)) + ])); + } + return redirect()->back() + ->with('error', trans('crud.messages.cannot_be_created', [ + 'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1)) + ])); + }); + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\Carousel $carousel + * @return \Illuminate\Contracts\View\View + */ + public function edit(Carousel $carousel): \Illuminate\Contracts\View\View + { + $sectionModels = Section::all(); + + return view('bo.pages.carousels.edit', [ + 'carouselModel' => $carousel, + 'sectionModels' => $sectionModels + ]); + } + + /** + * Update the specified resource in storage. + * + * @param \App\Http\Requests\Bo\Carousels\UpdateCarouselRequest $request + * @param \App\Models\Carousel $carousel + * @return \Illuminate\Http\RedirectResponse + */ + public function update(UpdateCarouselRequest $request, Carousel $carousel): \Illuminate\Http\RedirectResponse + { + return DB::transaction(function () use ($request, $carousel) { + $carousel->fill($request->validated()); + if (!Arr::exists($request->validated(), 'media')) { + $carousel->media = []; + } + + // Set the new pictures files in the pictures array. + collect($request->only(['media.pictures.*.path'])) + ->each( + function (mixed $value, string $attribute) use ($carousel) { + foreach ($value['pictures']['*']['path'] as $index => $file) { + if ($file instanceof \Illuminate\Http\UploadedFile) { + $carousel->setAttribute( + "{$attribute}->pictures->{$index}->path", + FileStorageHelper::storeFile($carousel, $file, true) + ); + } + } + } + ); + if ($carousel->saveOrFail()) { + return redirect()->route('bo.carousels.edit', $carousel) + ->with('success', trans('crud.messages.has_been_updated', [ + 'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1)) + ])); + } + return redirect()->route('bo.carousels.edit', $carousel) + ->with('error', trans('crud.messages.cannot_be_updated', [ + 'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1)) + ])); + }); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\Carousel $carousel + * @return \Illuminate\Http\RedirectResponse + */ + public function destroy(Carousel $carousel): \Illuminate\Http\RedirectResponse + { + if ($carousel->deleteOrFail()) { + return redirect()->route('bo.carousels.index') + ->with('success', trans('crud.messages.has_been_deleted', [ + 'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1)) + ])); + } + return redirect()->back() + ->with('error', trans('crud.messages.cannot_be_deleted', [ + 'model' => Str::ucfirst(trans_choice('models.classes.carousel', 1)) + ])); + } + + /** + * Duplicate the specified resource. + * + * @param \App\Models\Carousel $carousel + * @return \Illuminate\Contracts\View\View + */ + public function duplicate(Carousel $carousel): \Illuminate\Contracts\View\View + { + return $this->create($carousel->replicate()); + } +} diff --git a/app/Http/Controllers/Fo/StaticPageController.php b/app/Http/Controllers/Fo/StaticPageController.php index a97eaae..8490373 100644 --- a/app/Http/Controllers/Fo/StaticPageController.php +++ b/app/Http/Controllers/Fo/StaticPageController.php @@ -11,6 +11,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\Fo\ListenFormRequest; use App\Mail\SendConfirmationMail; use App\Mail\SendContactMail; +use App\Models\Carousel; use App\Models\HistoricalMilestone; use App\Models\JobVideo; use App\Models\Network; @@ -266,15 +267,16 @@ class StaticPageController extends Controller */ public function hire(): \Illuminate\Contracts\View\View { - $staticPageModel = StaticPage::query()->where('type', StaticPageType::we_hire)->first(); - $sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get(); - $videoModels = JobVideo::query()->inRandomOrder()->simplePaginate(4); - $testimonialModels = Testimonial::query()->where('type', TypeEnum::hire)->get(); - $compagnyLifeSection = $sectionModels->where('section', PageSectionEnum::hire_life)->first(); - $formationSection = $sectionModels->where('section', PageSectionEnum::hire_formation)->first(); - $testimonialSection = $sectionModels->where('section', PageSectionEnum::hire_grow)->first(); - $paritySection = $sectionModels->where('section', PageSectionEnum::hire_parity)->first(); - $findSection = $sectionModels->where('section', PageSectionEnum::hire_find)->first(); + $staticPageModel = StaticPage::query()->where('type', StaticPageType::we_hire)->first(); + $sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get(); + $videoModels = JobVideo::query()->inRandomOrder()->simplePaginate(4); + $testimonialModels = Testimonial::query()->where('type', TypeEnum::hire)->get(); + $compagnyLifeSection = $sectionModels->where('section', PageSectionEnum::hire_life)->first(); + $formationSection = $sectionModels->where('section', PageSectionEnum::hire_formation)->first(); + $testimonialSection = $sectionModels->where('section', PageSectionEnum::hire_grow)->first(); + $paritySection = $sectionModels->where('section', PageSectionEnum::hire_parity)->first(); + $findSection = $sectionModels->where('section', PageSectionEnum::hire_find)->first(); + $carouselSectionParity = Carousel::query()->where('section_id', PageSectionEnum::hire_parity)->where('published', true)->get(); $navLinks = Sticky::query()->where('type', StaticPageType::we_hire)->get(); return view('fo.pages.hire', \compact( @@ -287,6 +289,7 @@ class StaticPageController extends Controller 'testimonialSection', 'paritySection', 'findSection', + 'carouselSectionParity', 'navLinks' )); } diff --git a/app/Http/Requests/Bo/Carousels/StoreCarouselRequest.php b/app/Http/Requests/Bo/Carousels/StoreCarouselRequest.php new file mode 100644 index 0000000..72645de --- /dev/null +++ b/app/Http/Requests/Bo/Carousels/StoreCarouselRequest.php @@ -0,0 +1,127 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation(): void + { + if ($this->input('media.pictures')) { + foreach ($this->input('media.pictures') as $index => $pictureArray) { + $this->mergePicture("media.pictures.$index.path"); + } + } + + $this->merge([ + 'published' => $this->boolean('published'), + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + $rules = [ + 'title' => 'required|string|between:3,255', + 'section_id' => [ + 'required', + Rule::exists('sections', 'id'), + new IsMaxChildrenReached(new Section(), 'carousels', 5) + ], + 'media' => 'required|array', + 'media.pictures.*.alt' => 'sometimes|string|between:3,255', + 'media.pictures.*.title' => 'sometimes|string|between:3,255', + 'media.pictures.*.legend' => [ + 'sometimes', + 'string', + new WysiwygLength(3, 255), + ], + 'published' => 'required|boolean', + ]; + if ($this->input('media')) { + if (Arr::exists($this->input('media'), 'pictures')) { + foreach ($this->input('media')['pictures'] as $pictureIndex => $pictureArray) { + $rules = array_merge( + $rules, + [ + "media.pictures.$pictureIndex.alt" => 'required|string|between:3,255', + "media.pictures.$pictureIndex.title" => 'required|string|between:3,255', + "media.pictures.$pictureIndex.legend" => [ + 'sometimes', + 'string', + new WysiwygLength(3, 255), + ], + ], + $this->pictureRules("media.pictures.$pictureIndex.path", 500, 500, 500, 500, false), + ); + } + } //end if + } //end if + return $rules; + } + + /** + * Get custom attributes for validator errors. + * + * @return array + */ + public function attributes(): array + { + $attributes = [ + 'title' => trans('validation.attributes.title'), + ]; + if ($this->input('media') && array_key_exists('pictures', $this->input('media'))) { + foreach ($this->input('media.pictures') as $index => $pictureArray) { + $attributes = array_merge( + $attributes, + [ + "media.pictures.$index.alt" => trans(':field :inter:model', [ + 'field' => trans('validation.custom.alt_attribute'), + 'inter' => trans('validation.custom.of_the.vowel'), + 'model' => sprintf('%s n°%d', trans('validation.custom.picture'), $index + 1), + ]), + "media.pictures.$index.title" => trans(':field :inter:model', [ + 'field' => trans('validation.custom.title_attribute'), + 'inter' => trans('validation.custom.of_the.vowel'), + 'model' => sprintf('%s n°%d', trans('validation.custom.picture'), $index + 1), + ]), + "media.pictures.$index.legend" => trans(':field :inter:model', [ + 'field' => trans('validation.custom.legend'), + 'inter' => trans('validation.custom.of_the.vowel'), + 'model' => sprintf('%s n°%d', trans('validation.custom.picture'), $index + 1), + ]), + ], + ); + } //end foreach + } //end if + return $attributes; + } +} diff --git a/app/Http/Requests/Bo/Carousels/UpdateCarouselRequest.php b/app/Http/Requests/Bo/Carousels/UpdateCarouselRequest.php new file mode 100644 index 0000000..06e22f0 --- /dev/null +++ b/app/Http/Requests/Bo/Carousels/UpdateCarouselRequest.php @@ -0,0 +1,7 @@ + + */ + protected $fillable = [ + 'section_id', + 'title', + 'media', + 'order', + 'published', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'media' => 'array', + 'published' => 'boolean', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + $otherCarousels = self::query() + ->whereRelation('section', 'id', $model->section->id) + ->count(); + if ($otherCarousels > 4) { + throw new \RuntimeException('Creating more than 5 carousels is not allowed'); + } + self::setOrder($model); + }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFiles( + data_get(ToolboxHelper::getOriginal($model, 'media'), 'pictures.*.path', ['']), + data_get($model->media, 'pictures.*.path', ['']) + ); + }); + static::deleted(function (self $model) { + FileStorageHelper::removeOldFiles( + data_get($model->media, 'pictures.*.path', ['']), + [''] + ); + self::setOrder($model, true); + }); + } + + // * METHODS + + + /** + * Set order after the last element of the list. + * + * @param self $model + * @param boolean $isDeletion + * @return void + */ + private static function setOrder(self $model, bool $isDeletion = false): void + { + $maxOrder = \intval(self::query()->where('section_id', $model->section_id)->max('order')); + + if ($isDeletion) { + $request = Carousel::query() + ->where('section_id', $model->section_id) + ->whereNot('id', $model->id) + ->whereBetween('order', [$model->order, $maxOrder]); + $request->decrement('order', 1); + return; + } + + $model->order = $maxOrder + 1; + } + + + // * RELATIONSHIPS + + /** + * Get the sections that owns the Carousel + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function section(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Section::class); + } +} diff --git a/app/Models/Section.php b/app/Models/Section.php index b2d7f9e..40fb7bb 100644 --- a/app/Models/Section.php +++ b/app/Models/Section.php @@ -486,4 +486,14 @@ class Section extends Model { return $this->belongsTo(StaticPage::class); } + + /** + * Get the sections that own the carousel. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function carousels(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(Carousel::class); + } } diff --git a/app/Policies/CarouselPolicy.php b/app/Policies/CarouselPolicy.php new file mode 100644 index 0000000..07b71a1 --- /dev/null +++ b/app/Policies/CarouselPolicy.php @@ -0,0 +1,98 @@ +parentModel->where('id', $value)->first()->{$this->relationName}; + if (!is_null($this->idToIgnore)) { + $children = $children->where('id', '!==', $this->idToIgnore); + } + if ($children->count() >= $this->max) { + $parentName = str($this->parentModel->getTable())->singular(); + $childrenName = str($this->parentModel->{$this->relationName}()->getModel()->getTable())->singular(); + + $fail(trans('crud.messages.rule_max_reached', [ + 'parent' => str(trans_choice('models.classes.' . $parentName, 1))->title(), + 'max' => $this->max, + 'children' => str(trans_choice('models.classes.' . $childrenName, 1))->title()->plural() + ])); + } + } +} diff --git a/database/migrations/2026_03_10_154341_alter_sections_hire_page.php b/database/migrations/2026_03_10_154341_alter_sections_hire_page.php new file mode 100644 index 0000000..5ed3157 --- /dev/null +++ b/database/migrations/2026_03_10_154341_alter_sections_hire_page.php @@ -0,0 +1,242 @@ +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; + }); + + Collection::macro('insertBefore', function ($target, $value, $new_key = null) { + if (is_int($target)) { + $this->items = array_merge(array_slice($this->items, 0, $target), [$value], array_slice($this->items, $target)); + return; + } + foreach ($this->items as $key => $old) { + if ($key === $target && is_null($new_key)) { + $new[] = $value; + } elseif ($key === $target) { + $new[$new_key] = $value; + } + $new[$key] = $old; + } + $this->items = $new; + }); + + Collection::macro('replaceItem', function ($target, $value, $new_key = null) { + $new = []; + foreach ($this->items as $key => $old) { + if ($key === $target) { + $new[$new_key ?? $key] = $value; + } else { + $new[$key] = $old; + } + } + $this->items = $new; + }); + } + + /** + * Run the migrations. + */ + public function up(): void + { + $this->registerMacros(); + + $hireParitySection = Section::query()->where('section', PageSectionEnum::hire_parity)->first(); + if ($hireParitySection) { + $data = collect($hireParitySection->data); + $contentImage = collect(Section::emptyPictureBloc( + [], + '', + '', + '', + 1400, + 788, + false, + 'Image n°1' + ))->first(); + + $data->replaceItem( + "bloc_image_n1", + $contentImage + ); + + $contentTitle2 = collect(Section::emptyStringBloc( + [], + 'Titre de la section n°2', + 'L\'humain au cœur de nos préoccupations', + true + ))->first(); + + $data->insertBefore( + "bloc_contenu_n2_content", + $contentTitle2, + "bloc_title_n2" + ); + + $data->forget("bloc_image_n2"); + + $contentTitle3 = collect(Section::emptyStringBloc( + [], + 'Titre de la section n°3', + 'Ensemble, on passe de bons moments', + true + ))->first(); + + $data->insertBefore( + "bloc_contenu_n3_content", + $contentTitle3, + "bloc_title_n3" + ); + + $contentTitle4 = collect(Section::emptyStringBloc( + [], + 'Titre de la section n°4', + 'Évènements conviviaux organisés par les sites :', + true + ))->first(); + + $data->insertAfter( + "bloc_contenu_n3_content", + $contentTitle4, + "bloc_title_n4" + ); + + $contentDesc = collect(Section::emptyWysiwygBloc( + [], + 'Contenu n°4', + clean(\fake()->randomHtml()), + ))->first(); + + $data->insertAfter( + "bloc_title_n4", + $contentDesc, + "bloc_contenu_n4_content" + ); + + $hireParitySection->data = $data->all(); + $hireParitySection->saveQuietly(); + } + + $hireFormationSection = Section::query()->where('section', PageSectionEnum::hire_formation)->first(); + if ($hireFormationSection) { + $data = collect($hireFormationSection->data); + $contentImage = collect(Section::emptyPictureBloc( + [], + '', + '', + '', + 1400, + 788, + false, + 'Image n°1' + ))->first(); + + $data->replaceItem( + "bloc_image_n1", + $contentImage + ); + + $hireFormationSection->data = $data->all(); + $hireFormationSection->saveQuietly(); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $this->registerMacros(); + + $hireParitySection = Section::query()->where('section', PageSectionEnum::hire_parity)->first(); + if ($hireParitySection) { + $data = collect($hireParitySection->data)->except( + "bloc_title_n2", + "bloc_title_n3", + "bloc_title_n4", + "bloc_contenu_n4_content", + ); + + $contentImage = collect(Section::emptyPictureBloc( + [], + 'storage/modelfiles/sections/25/09/19/c2/20241013-103605-68cd8a6285dac.jpg', + 'Mobilisation de l\'ensemble de nos équipes lors de la campagne Octobre Rose 2023', + 'Mobilisation de l\'ensemble de nos équipes lors de la campagne Octobre Rose 2023', + 1400, + 788, + true, + 'Image n°1' + ))->first(); + + $data->replaceItem( + "bloc_image_n1", + $contentImage + ); + + $contentImage2 = collect(Section::emptyPictureBloc( + [], + 'storage/modelfiles/sections/25/09/19/c1/dsc01088-68cd8c5dc85bd.jpg', + 'Animations sommeils : Gerer le sommeil quand on est en horaires décalés', + 'Animations sommeils : Gerer le sommeil quand on est en horaires décalés', + 1400, + 788, + true, + 'Image n°2' + ))->first(); + + $data->insertBefore( + "bloc_contenu_n2_content", + $contentImage2, + "bloc_image_n2" + ); + + $hireParitySection->data = $data->all(); + $hireParitySection->saveQuietly(); + } + + $hireFormationSection = Section::query()->where('section', PageSectionEnum::hire_formation)->first(); + if ($hireFormationSection) { + $data = collect($hireFormationSection->data); + $contentImage = collect(Section::emptyPictureBloc( + [], + '', + '', + '', + 1400, + 788, + true, + 'Image n°1' + ))->first(); + + $data->replaceItem( + "bloc_image_n1", + $contentImage + ); + + $hireFormationSection->data = $data->all(); + $hireFormationSection->saveQuietly(); + } + } +}; diff --git a/database/migrations/2026_03_11_093952_create_carousels_table.php b/database/migrations/2026_03_11_093952_create_carousels_table.php new file mode 100644 index 0000000..7049278 --- /dev/null +++ b/database/migrations/2026_03_11_093952_create_carousels_table.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId('section_id')->constrained('sections')->comment('Id of the section associated'); + $table->string('title')->comment('Title of the carousel'); + $table->json('media')->comment('0-5 images + alt/title/legend'); + $table->integer('order')->comment('Position of the carousels'); + $table->boolean('published')->comment('Is the carousel published ?'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('carousels'); + } +}; diff --git a/database/seeders/Development/SectionSeeder.php b/database/seeders/Development/SectionSeeder.php index 5d83b6b..0665106 100644 --- a/database/seeders/Development/SectionSeeder.php +++ b/database/seeders/Development/SectionSeeder.php @@ -247,7 +247,7 @@ class SectionSeeder extends Seeder new \SplFileInfo(\resource_path( '../database/factories/assets/sections/default-picture-1400x788.png' )) - ), fake()->sentence(), fake()->sentence(), 1400, 788, true, 'Bannière'); + ), fake()->sentence(), fake()->sentence(), 1400, 788, false, 'Bannière'); $data = array_merge( $data, $section->emptyWysiwygBloc([], "Contenu n°1", clean(\fake()->randomHtml())) @@ -257,21 +257,31 @@ class SectionSeeder extends Seeder new \SplFileInfo(\resource_path( '../database/factories/assets/sections/default-picture-1400x788.png' )) - ), fake()->sentence(), fake()->sentence(), 1400, 788, true, 'Image n°1')); + ), fake()->sentence(), fake()->sentence(), 1400, 788, false, 'Image n°1')); + $data = array_merge( + $data, + $section->emptyStringBloc([], "Titre de la section n°2", \fake()->text(50)) + ); $data = array_merge( $data, $section->emptyWysiwygBloc([], "Contenu n°2", clean(\fake()->randomHtml())) ); - $data = array_merge($data, $section->emptyPictureBloc([], FileStorageHelper::storeFile( - new Section(), - new \SplFileInfo(\resource_path( - '../database/factories/assets/sections/default-picture-1400x788.png' - )) - ), fake()->sentence(), fake()->sentence(), 1400, 788, true, 'Image n°2')); + $data = array_merge( + $data, + $section->emptyStringBloc([], "Titre de la section n°3", \fake()->text(50)) + ); $data = array_merge( $data, $section->emptyWysiwygBloc([], "Contenu n°3", clean(\fake()->randomHtml())) ); + $data = array_merge( + $data, + $section->emptyStringBloc([], "Titre de la section n°4", \fake()->text(50)) + ); + $data = array_merge( + $data, + $section->emptyWysiwygBloc([], "Contenu n°4", clean(\fake()->randomHtml())) + ); $data = array_merge($data, $section->emptyButtonBooleanBloc([], 'On Bouge Ensemble')); return $data; diff --git a/resources/lang/fr/crud.php b/resources/lang/fr/crud.php index 21bae99..5ebab68 100644 --- a/resources/lang/fr/crud.php +++ b/resources/lang/fr/crud.php @@ -42,6 +42,7 @@ return [ 'right' => 'Vous n\'avez pas les droits pour accéder à cette partie !', 'theme_updated' => 'Le thème a été mis à jour !', 'user_unpublished' => 'Vous ne pouvez pas désactiver votre propre compte !', + 'rule_max_reached' => 'L\'élement :parent ne peut pas avoir plus de :max :children', ], 'minicrud' => [ 'visibility_label' => 'Visibilité', diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index c91a620..d219ee3 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -17,6 +17,7 @@ return [ 'network' => 'réseau|réseaux', 'aisle' => 'rayon', 'brand' => 'marque', + 'carousel' => 'carrousel|carrousels' 'sticky' => 'menu d\'ancre|menu d\'ancres' ] ]; diff --git a/resources/sass/fo/fo.scss b/resources/sass/fo/fo.scss index 6546a50..d137327 100644 --- a/resources/sass/fo/fo.scss +++ b/resources/sass/fo/fo.scss @@ -29,3 +29,4 @@ // * PARTIALS @import "./partials/slider"; @import "./partials/testimonial-card"; +@import "./partials/carousel"; diff --git a/resources/sass/fo/partials/_carousel.scss b/resources/sass/fo/partials/_carousel.scss new file mode 100644 index 0000000..7e8240b --- /dev/null +++ b/resources/sass/fo/partials/_carousel.scss @@ -0,0 +1,31 @@ + +@use "sass:color"; + +.swiper-carousels { + .swiper-carousels-pagination { + bottom: 2rem; + left: 5%; + + @include media-breakpoint-up(lg) { + top: auto; + bottom: .5rem; + left: 0; + width: 100%; + } + } + + .swiper-pagination-bullet { + width: 3rem; + max-width: 10rem; + height: .5rem; + background-color: color.adjust($color-dark, $alpha: -0.8); + + &:hover { + cursor: pointer; + } + } + + .swiper-pagination-bullet-active { + background-color: $color-primary; + } +} diff --git a/resources/ts/bo/components/ListItemComponent.vue b/resources/ts/bo/components/ListItemComponent.vue new file mode 100644 index 0000000..8b8a493 --- /dev/null +++ b/resources/ts/bo/components/ListItemComponent.vue @@ -0,0 +1,306 @@ + + + + + diff --git a/resources/ts/fo/base/common.ts b/resources/ts/fo/base/common.ts index 1e2a948..3a07c40 100644 --- a/resources/ts/fo/base/common.ts +++ b/resources/ts/fo/base/common.ts @@ -346,6 +346,42 @@ document.addEventListener("DOMContentLoaded", function () { }, }, }, + "swiper-carousels": { + modules: [Pagination], + grabCursor: true, + slidesPerView: 1, + spaceBetween: 15, + centeredSlides: true, + initialSlide: 0, + speed: 750, + pagination: { + el: ".swiper-carousels-pagination", + clickable: true, + renderBullet: function (index: number, className: string) { + return ""; + }, + }, + breakpoints: { + 576: { + slidesPerView: 1.5, + }, + 768: { + slidesPerView: 2, + }, + 992: { + slidesPerView: 2.5, + }, + }, + on: { + beforeInit(swiper: Swiper) { + const slideCount = swiper.el.querySelectorAll(".swiper-slide").length; + + if (slideCount !== 2) { + swiper.params.initialSlide = Math.floor(slideCount / 2); + } + } + } + }, }; const swiperVol = document.getElementsByClassName("swiper") as HTMLCollectionOf; diff --git a/resources/views/bo/layouts/nav-list.blade.php b/resources/views/bo/layouts/nav-list.blade.php index 15bf466..8a34af5 100644 --- a/resources/views/bo/layouts/nav-list.blade.php +++ b/resources/views/bo/layouts/nav-list.blade.php @@ -109,7 +109,7 @@ {{-- WE HIRE --}} @endcan + @can('viewAny', \App\Models\Carousel::class) + + @endcan @can('viewAny', \App\Models\Testimonial::class)