diff --git a/app/Http/Controllers/Bo/BrandAdvantageController.php b/app/Http/Controllers/Bo/BrandAdvantageController.php index d43434c1..58785760 100644 --- a/app/Http/Controllers/Bo/BrandAdvantageController.php +++ b/app/Http/Controllers/Bo/BrandAdvantageController.php @@ -166,8 +166,8 @@ class BrandAdvantageController extends Controller ])); } return redirect()->back() - ->with('error', __('crud.messages.cannot_be_deleted', [ - 'model' => str(__('models.classebrand_advantage'))->ucfirst() + ->with('error', trans('crud.messages.cannot_be_deleted', [ + 'model' => str(trans('models.classebrand_advantage'))->ucfirst() ])); } diff --git a/app/Http/Controllers/Bo/NewsCategoryController.php b/app/Http/Controllers/Bo/NewsCategoryController.php new file mode 100644 index 00000000..08db1a1b --- /dev/null +++ b/app/Http/Controllers/Bo/NewsCategoryController.php @@ -0,0 +1,179 @@ +authorizeResource(NewsCategory::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 $newsCategoryModels */ + $newsCategoryModels = NewsCategory::query(); + + /** @var string $search Search field */ + $search = $request->search; + if ($search) { + $this->searchQuery( + $newsCategoryModels, + $search, + null, + 'title', + ); + } + $searchFields = \implode(', ', [ + trans('validation.attributes.title'), + ]); + + /** Sort columns with a query */ + $this->sortQuery($newsCategoryModels); + + /** Custom pagination */ + $newsCategoryModels = $this->paginate($newsCategoryModels); + + return view('bo.pages.news_categories.index', compact('newsCategoryModels', 'search', 'searchFields')); + } + + /** + * Show the form for creating a new resource. + * + * @param \App\Models\NewsCategory $newsCategory + * @return \Illuminate\Contracts\View\View + */ + public function create(NewsCategory $newsCategory): \Illuminate\Contracts\View\View + { + return view('bo.pages.news_categories.create', ['newsCategoryModel' => $newsCategory]); + } + + /** + * Store a newly created resource in storage. + * + * @param \App\Http\Requests\Bo\NewsCategories\StoreNewsCategoryRequest $request + * @return \Illuminate\Http\RedirectResponse + */ + public function store(StoreNewsCategoryRequest $request): \Illuminate\Http\RedirectResponse + { + return DB::transaction(function () use ($request) { + $newsCategory = new NewsCategory(); + $newsCategory->fill($request->validated()); + + if ($newsCategory->saveOrFail()) { + return redirect()->route('bo.news_categories.edit', $newsCategory) + ->with('success', __('crud.messages.has_been_created', [ + 'model' => Str::ucfirst(__('models.classes.news_category')) + ])); + } + return redirect()->back() + ->with('error', __('crud.messages.cannot_be_created', [ + 'model' => Str::ucfirst(__('models.classes.news_category')) + ])); + }); + } + + /** + * Display the specified resource. + * + * @param \App\Models\NewsCategory $newsCategory + * @return \Illuminate\Contracts\View\View + */ + public function show(NewsCategory $newsCategory): \Illuminate\Contracts\View\View + { + return view('bo.pages.news_categories.show', ['newsCategoryModel' => $newsCategory]); + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\NewsCategory $newsCategory + * @return \Illuminate\Contracts\View\View + */ + public function edit(NewsCategory $newsCategory): \Illuminate\Contracts\View\View + { + return view('bo.pages.news_categories.edit', ['newsCategoryModel' => $newsCategory]); + } + + /** + * Update the specified resource in storage. + * + * @param \App\Http\Requests\Bo\NewsCategories\UpdateNewsCategoryRequest $request + * @param \App\Models\NewsCategory $newsCategory + * @return \Illuminate\Http\RedirectResponse + */ + public function update( + UpdateNewsCategoryRequest $request, + NewsCategory $newsCategory + ): \Illuminate\Http\RedirectResponse { + return DB::transaction(function () use ($request, $newsCategory) { + $newsCategory->fill($request->validated()); + + if ($newsCategory->saveOrFail()) { + return redirect()->route('bo.news_categories.edit', $newsCategory) + ->with('success', trans('crud.messages.has_been_updated', [ + 'model' => Str::ucfirst(trans('models.classes.news_category')) + ])); + } + return redirect()->route('bo.news_categories.edit', $newsCategory) + ->with('error', trans('crud.messages.cannot_be_updated', [ + 'model' => Str::ucfirst(trans('models.classes.news_category')) + ])); + }); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\NewsCategory $newsCategory + * @return \Illuminate\Http\RedirectResponse + */ + public function destroy(NewsCategory $newsCategory): \Illuminate\Http\RedirectResponse + { + /** @var array */ + $previousQueries = []; + \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + if ($newsCategory->deleteOrFail()) { + return redirect()->route('bo.news_categories.index', $previousQueries) + ->with('success', trans('crud.messages.has_been_deleted', [ + 'model' => Str::ucfirst(trans('models.classes.news_category')) + ])); + } + return redirect()->back() + ->with('error', trans('crud.messages.cannot_be_deleted', [ + 'model' => Str::ucfirst(trans('models.classes.news_category')) + ])); + } + + /** + * Duplicate the specified resource. + * + * @param \App\Models\NewsCategory $newsCategory + * @return \Illuminate\Contracts\View\View + */ + public function duplicate(NewsCategory $newsCategory): \Illuminate\Contracts\View\View + { + return $this->create($newsCategory->replicate()); + } +} diff --git a/app/Http/Requests/Bo/NewsCategories/StoreNewsCategoryRequest.php b/app/Http/Requests/Bo/NewsCategories/StoreNewsCategoryRequest.php new file mode 100644 index 00000000..a06f0e2a --- /dev/null +++ b/app/Http/Requests/Bo/NewsCategories/StoreNewsCategoryRequest.php @@ -0,0 +1,62 @@ +merge([ + 'published' => $this->boolean('published'), + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'seo_title' => 'required|string|between:45,70', + 'seo_description' => 'required|string|between:50,160', + 'title' => 'required|string|between:3,255', + 'published' => 'required|boolean', + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array + */ + public function attributes(): array + { + return [ + 'seo_title' => trans('validation.attributes.title'), + 'seo_description' => trans('validation.attributes.title'), + 'title' => trans('validation.attributes.title'), + 'published' => trans('validation.attributes.published'), + ]; + } +} diff --git a/app/Http/Requests/Bo/NewsCategories/UpdateNewsCategoryRequest.php b/app/Http/Requests/Bo/NewsCategories/UpdateNewsCategoryRequest.php new file mode 100644 index 00000000..524fa1ba --- /dev/null +++ b/app/Http/Requests/Bo/NewsCategories/UpdateNewsCategoryRequest.php @@ -0,0 +1,18 @@ +route('news_category')); + } +} diff --git a/app/Models/NewsCategory.php b/app/Models/NewsCategory.php new file mode 100644 index 00000000..7b75e132 --- /dev/null +++ b/app/Models/NewsCategory.php @@ -0,0 +1,103 @@ + + */ + protected $fillable = [ + 'title', + 'seo_title', + 'seo_description', + 'slug', + 'published', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'published' => 'boolean' + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $newsCorporate) { + self::setOrder($newsCorporate); + self::assertLabelIsUnique($newsCorporate->title); + self::manageFields($newsCorporate); + }); + static::updating(function (self $newsCorporate) { + self::assertLabelIsUnique($newsCorporate->title); + self::manageFields($newsCorporate); + }); + } + + // * METHODS + + /** + * Set model's order after the last element of the list. + * + * @param self $mainSlide + * @return void + */ + private static function setOrder(self $mainSlide): void + { + $mainSlide->order = \intval(self::query()->max('order')) + 1; + } + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + $model->slug = Str::slug($model->title); + } + + /** + * Asserts using validation that the label is unique + * + * @param string|null $label + * @param integer|null $id + * @return void + * @throws \Illuminate\Validation\ValidationException If a meat label already exists. + */ + private static function assertLabelIsUnique(string|null $label, ?int $id = null) + { + $table = (new self())->getTable(); + ToolboxHelper::assertFieldIsUnique($table, 'slug', Str::slug($label), $id); + } +} diff --git a/app/Policies/NewsCategoryPolicy.php b/app/Policies/NewsCategoryPolicy.php new file mode 100644 index 00000000..f4331787 --- /dev/null +++ b/app/Policies/NewsCategoryPolicy.php @@ -0,0 +1,97 @@ + + */ +class NewsCategoryFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $title = fake()->unique()->words(rand(1, 2), true); + return [ + 'seo_title' => fake()->sentence(), + 'seo_description' => fake()->sentence(), + 'title' => $title, + 'slug' => Str::slug($title), + 'published' => fake()->boolean(75), + ]; + } +} diff --git a/database/migrations/2024_08_09_155605_create_news_categories_table.php b/database/migrations/2024_08_09_155605_create_news_categories_table.php new file mode 100644 index 00000000..8d9f85f6 --- /dev/null +++ b/database/migrations/2024_08_09_155605_create_news_categories_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('seo_title')->comment('The seo title of the news category.'); + $table->string('seo_description')->comment('The seo description of the news category.'); + $table->string('title')->comment('News category title.'); + $table->string('slug')->unique()->comment('News category title slug.'); + $table->integer('order')->comment('News category order.'); + $table->boolean('published')->comment('News category publish status.'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('news_categories'); + } +}; diff --git a/database/seeders/Development/NewsCategorySeeder.php b/database/seeders/Development/NewsCategorySeeder.php new file mode 100644 index 00000000..a3d6b113 --- /dev/null +++ b/database/seeders/Development/NewsCategorySeeder.php @@ -0,0 +1,29 @@ +make()->each(function (NewsCategory $newsCategory, int $key) { + $newsCategory->order = $key + 1; + $newsCategory->saveQuietly(); + }); + } +} diff --git a/database/seeders/DevelopmentSeeder.php b/database/seeders/DevelopmentSeeder.php index ca24664e..2e52de1c 100644 --- a/database/seeders/DevelopmentSeeder.php +++ b/database/seeders/DevelopmentSeeder.php @@ -14,6 +14,7 @@ use Database\Seeders\Development\DepartaimantCollectionSeeder; use Database\Seeders\Development\IncoNutritionalValueSeeder; use Database\Seeders\Development\MainSlideSeeder; use Database\Seeders\Development\MeatSeeder; +use Database\Seeders\Development\NewsCategorySeeder; use Database\Seeders\Development\ProductSeeder; use Database\Seeders\Development\RangeSeeder; use Database\Seeders\Development\RecipeSeeder; @@ -52,8 +53,9 @@ class DevelopmentSeeder extends Seeder RecipeSeeder::class, IncoNutritionalValueSeeder::class, DepartaimantCollectionSeeder::class, - NewsCorporateSeeder::class + NewsCorporateSeeder::class, TestimonialSeeder::class, + NewsCategorySeeder::class, ]); } } diff --git a/resources/lang/en/models.php b/resources/lang/en/models.php index 5fb70f8e..aa9ac2f8 100644 --- a/resources/lang/en/models.php +++ b/resources/lang/en/models.php @@ -27,6 +27,6 @@ return [ 'claim' => 'claim', 'historical_milestone' => 'historical milestone|historical milestones', 'offer' => 'offer', - 'news_corporate' => 'news of the compagny' + 'news_category' => 'category of the news', ] ]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index a91f723c..032ea3ff 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -244,6 +244,7 @@ return [ 'button_text' => 'button text', 'button_url' => 'button url', 'button' => 'button', + 'category' => 'category', 'claim' => 'claim', 'color_block' => 'color block', 'color' => 'color', diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index a6247968..25941eb7 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -28,6 +28,6 @@ return [ 'historical_milestone' => 'jalon historique|jalons historique', 'offer' => 'offre', 'news_corporate' => 'actualités de l\'entreprise', - 'testimonial' => 'témoignage', + 'news_category' => 'catégorie d\'une actualité', ] ]; diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index 9112c014..62115e60 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -244,6 +244,7 @@ return [ 'button_text' => 'texte du bouton', 'button_url' => 'lien du bouton', 'button' => 'bouton', + 'category' => 'catégorie', 'claim' => 'allégation', 'color_block' => 'couleur du block', 'color' => 'couleur', diff --git a/resources/views/bo/layouts/sidemenu.blade.php b/resources/views/bo/layouts/sidemenu.blade.php index 88a7fce8..2830ede7 100644 --- a/resources/views/bo/layouts/sidemenu.blade.php +++ b/resources/views/bo/layouts/sidemenu.blade.php @@ -817,6 +817,34 @@ + {{-- ACTUALITES --}} + +
{{-- LEGALS CGU --}} $newsCategoryModel]) + +@section('title', __('Création d\'une :model', ['model' => __('models.classes.news_category')])) +@section('description', __('Création d\'une tout nouveau :model', ['model' => __('models.classes.news_category')])) +@section('breadcrumb', request()->route()->getName()) + +@section('content') +
+
+ + + + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $newsCategoryModel]) +
+
+ +
+
+
+ @csrf + @include('bo.pages.news_categories.form') + @include('bo.partials.script-button-clone') +
+
+ +
+
+
+@endsection diff --git a/resources/views/bo/pages/news_categories/edit.blade.php b/resources/views/bo/pages/news_categories/edit.blade.php new file mode 100644 index 00000000..5ea1067c --- /dev/null +++ b/resources/views/bo/pages/news_categories/edit.blade.php @@ -0,0 +1,58 @@ +@extends('bo.layout', ['brParam' => $newsCategoryModel]) + +@section('title', __('Édition d\'une :model', ['model' => __('models.classes.news_category')])) +@section('description', __('Édition d\'une :model déjà existant', ['model' => __('models.classes.news_category')])) +@section('breadcrumb', request()->route()->getName()) + +@section('content') +
+
+ + + + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $newsCategoryModel]) +
+
+
+ @can('view', $newsCategoryModel) + + + + @endcan + @can('duplicate', $newsCategoryModel) + + + + @endcan + + @can('delete', $newsCategoryModel) + @csrf + @method('DELETE') + + @endcan +
+
+
+
+ @csrf + @method('PUT') + @include('bo.pages.news_categories.form') + @include('bo.partials.script-button-clone') +
+
+ +
+
+
+@endsection diff --git a/resources/views/bo/pages/news_categories/form.blade.php b/resources/views/bo/pages/news_categories/form.blade.php new file mode 100644 index 00000000..7cd11688 --- /dev/null +++ b/resources/views/bo/pages/news_categories/form.blade.php @@ -0,0 +1,136 @@ +
+ {{-- SEO_TITLE --}} +
+
+ {{ str(__('validation.custom.seo_title'))->ucfirst() }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'newsCategorySeoTitle', + 'label' => __(':field :inter:model', [ + 'field' => str(__('validation.custom.seo_title'))->ucfirst(), + 'inter' => __('validation.custom.of_the.female'), + 'model' => trans('models.classes.news_category'), + ]), + 'hasWordCounter' => true, + 'name' => 'seo_title', + 'required' => true, + 'model' => $newsCategoryModel ?? 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' => trans('models.classes.news_category'), + ]), + 'min' => 45, + 'max' => 70, + ])), + 'placeholder' => __(':field :inter:model', [ + 'field' => str(__('validation.custom.seo_title'))->ucfirst(), + 'inter' => __('validation.custom.of_the.female'), + 'model' => trans('models.classes.news_category'), + ]), + ]) +
+
+
+
+ {{-- SEO_DESCRIPTION --}} +
+
+ {{ str(__('validation.custom.seo_description'))->ucfirst() }} +
+
+ @include('bo.partials.inputs.varchar-multiline', [ + 'id' => 'newsCategorySeoDescription', + 'label' => __(':field :inter:model', [ + 'field' => str(__('validation.custom.seo_description'))->ucfirst(), + 'inter' => __('validation.custom.of_the.female'), + 'model' => trans('models.classes.news_category'), + ]), + 'name' => 'seo_description', + 'model' => $newsCategoryModel ?? null, + 'required' => true, + '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' => trans('models.classes.news_category'), + ]), + 'min' => 50, + 'max' => 160, + ])), + 'placeholder' => __(':field :inter:model', [ + 'field' => str(__('validation.custom.seo_description'))->ucfirst(), + 'inter' => __('validation.custom.of_the.female'), + 'model' => trans('models.classes.news_category'), + ]), + ]) +
+
+
+
+ {{-- TITLE --}} +
+
+ {{ str(__('validation.attributes.title'))->ucFirst() }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'newsCategoryTitle', + 'label' => __(':field :inter:model', [ + 'field' => str(__('validation.attributes.title'))->ucFirst(), + 'inter' => __('validation.custom.of_the.vowel'), + 'model' => __('models.classes.news_category'), + ]), + 'hasWordCounter' => true, + 'name' => 'title', + 'required' => true, + 'model' => $newsCategoryModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field :inter:model', [ + 'field' => __('validation.attributes.title'), + 'inter' => __('validation.custom.of_the.vowel'), + 'model' => __('models.classes.news_category'), + ]), + 'min' => 3, + 'max' => 255, + ]), + 'placeholder' => __(':field :inter:model', [ + 'field' => str(__('validation.attributes.title'))->ucFirst(), + 'inter' => __('validation.custom.of_the.vowel'), + 'model' => __('models.classes.news_category'), + ]), + ]) +
+
+
+
+ {{-- PUBLICATION --}} +
+
+ {{ str(__('crud.minicrud.visibility_label'))->ucFirst() }} +
+ {{-- PUBLISHED --}} +
+ @include('bo.partials.inputs.tinyint-boolean', [ + 'id' => 'newsCategoryPublished', + 'name' => 'published', + 'model' => $newsCategoryModel ?? null, + 'label' => __('crud.minicrud.visibility_label'), + 'helper' => sprintf('%s %s', __('crud.minicrud.visibility_helper'), __('crud.helpers.visibility_with_dates')), + ]) +
+
+
+
+
+

{{ __('* Champs obligatoires') }}

+
+
diff --git a/resources/views/bo/pages/news_categories/index-list.blade.php b/resources/views/bo/pages/news_categories/index-list.blade.php new file mode 100644 index 00000000..2ee3f4fa --- /dev/null +++ b/resources/views/bo/pages/news_categories/index-list.blade.php @@ -0,0 +1,75 @@ + + @if (count($newsCategoryModels)) + + @include('bo.modules.table-col-sorter', [ + 'cols' => [ + 'title' => str(__('validation.attributes.title'))->ucfirst(), + 'slug' => str(__('validation.custom.slug'))->ucfirst(), + 'published' => str(__('validation.custom.publication'))->ucfirst(), + 'updated_at' => str(__('validation.attributes.updated_at'))->ucfirst(), + ], + ]) + + + @foreach ($newsCategoryModels as $newsCategoryModel) + + + + @include('bo.modules.change-published-status', [ + 'routeName' => 'news_categories', + 'model' => $newsCategoryModel, + ]) + + + + @endforeach + + @else + + + + @endif +
{{ $newsCategoryModel->title }}{{ $newsCategoryModel->slug }} + {{ $newsCategoryModel->updated_at->isoFormat('LLLL') }} + + @canAny(['show', 'duplicate', 'update', 'delete'], $newsCategoryModel) +
+ @can('view', $newsCategoryModel) + + + + @endcan + @can('duplicate', $newsCategoryModel) + + + + @endcan + @can('update', $newsCategoryModel) + + + + @endcan + @can('delete', $newsCategoryModel) + @csrf + @method('DELETE') + + @endcan +
+ @else + + + + @endcan +
+ {{ trans_choice('crud.other.no_model_found', 1, ['model' => __('models.classes.news_category')]) }} +
diff --git a/resources/views/bo/pages/news_categories/index.blade.php b/resources/views/bo/pages/news_categories/index.blade.php new file mode 100644 index 00000000..28c851c1 --- /dev/null +++ b/resources/views/bo/pages/news_categories/index.blade.php @@ -0,0 +1,21 @@ +@extends('bo.layout') + +@section('title', str(__('models.classes.news_category'))->ucfirst()->plural()) +@section('description', __('Liste de tous les :model', ['model' => str(__('models.classes.news_category'))->plural()])) + +@section('content') +
+ @include('modules.breadcrumbs.breadcrumb-body') + @can('create', \App\Models\NewsCategory::class) + + + + @endcan +
+ @include('bo.modules.search-bar') +
+ @include('bo.pages.news_categories.index-list') +
+ {{ $newsCategoryModels->links() }} +@endsection diff --git a/resources/views/bo/pages/news_categories/show.blade.php b/resources/views/bo/pages/news_categories/show.blade.php new file mode 100644 index 00000000..5a6edd42 --- /dev/null +++ b/resources/views/bo/pages/news_categories/show.blade.php @@ -0,0 +1,95 @@ +@extends('bo.layout', ['brParam' => $newsCategoryModel]) + +@section('title', __('Aperçu d\'un :model', ['model' => __('models.classes.news_category')])) +@section('description', __('Aperçu d\'un :model déjà existante', ['model' => __('models.classes.news_category')])) +@section('breadcrumb', request()->route()->getName()) + +@section('content') +
+
+ + + + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $newsCategoryModel]) +
+ @canAny(['duplicate', 'update', 'delete'], $newsCategoryModel) +
+ @can('duplicate', $newsCategoryModel) + + + + @endcan + @can('update', $newsCategoryModel) + + + + @endcan + @can('delete', $newsCategoryModel) + @csrf + @method('DELETE') + + @endcan +
+ @endcan +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ str(__('validation.attributes.title'))->ucFirst() }} + {{ $newsCategoryModel->title }} +
{{ str(__('validation.custom.seo_title'))->ucFirst() }} + {{ $newsModel->seo_title }} +
{{ str(__('validation.custom.seo_description'))->ucFirst() }} + {{ $newsModel->seo_description }} +
+ {{ str(__('validation.custom.publication'))->ucFirst() }} + + {{ $newsCategoryModel->published + ? str($newsCategoryModel->created_at->isoFormat('LLLL'))->ucFirst() + : __('crud.other.model_not_published') }} +
{{ str(__('validation.attributes.created_at'))->ucFirst() }} + {{ str($newsCategoryModel->created_at->isoFormat('LLLL'))->ucFirst() }} +
{{ str(__('validation.attributes.updated_at'))->ucFirst() }} + {{ str($newsCategoryModel->updated_at->isoFormat('LLLL'))->ucFirst() }} +
+
+
+
+@endsection diff --git a/routes/breadcrumbs-bo.php b/routes/breadcrumbs-bo.php index 8ab474ec..39686035 100644 --- a/routes/breadcrumbs-bo.php +++ b/routes/breadcrumbs-bo.php @@ -13,6 +13,7 @@ use App\Models\MainSlide; use App\Models\GeneralSetting; use App\Models\HistoricalMilestone; use App\Models\Meat; +use App\Models\NewsCategory; use App\Models\NewsCorporate; use App\Models\Offer; use App\Models\Product; @@ -604,3 +605,27 @@ Breadcrumbs::for('bo.news_corporates.duplicate', function (Generator $trail) { $trail->parent('bo.news_corporates.index'); $trail->push(Str::ucfirst(trans('crud.actions.duplicate'))); }); + +// * NEWS CATEGORY +Breadcrumbs::for('bo.news_categories.index', function (Generator $trail) { + $trail->push( + Str::of(trans('models.classes.news_category'))->plural()->ucfirst(), + route('bo.news_categories.index') + ); +}); +Breadcrumbs::for('bo.news_categories.show', function (Generator $trail, NewsCategory $newsCategory) { + $trail->parent('bo.news_categories.index'); + $trail->push(Str::ucfirst(trans('crud.actions.view')), route('bo.news_categories.show', $newsCategory)); +}); +Breadcrumbs::for('bo.news_categories.create', function (Generator $trail) { + $trail->parent('bo.news_categories.index'); + $trail->push(Str::ucfirst(trans('crud.actions.create')), route('bo.news_categories.create')); +}); +Breadcrumbs::for('bo.news_categories.edit', function (Generator $trail, NewsCategory $newsCategory) { + $trail->parent('bo.news_categories.index'); + $trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.news_categories.edit', $newsCategory)); +}); +Breadcrumbs::for('bo.news_categories.duplicate', function (Generator $trail) { + $trail->parent('bo.news_categories.index'); + $trail->push(Str::ucfirst(trans('crud.actions.duplicate'))); +}); diff --git a/routes/web-bo.php b/routes/web-bo.php index 60d1324b..6941373d 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -13,6 +13,7 @@ use App\Http\Controllers\Bo\KeyNumberController; use App\Http\Controllers\Bo\MainSlideController; use App\Http\Controllers\Bo\MenuNodeDataController; use App\Http\Controllers\Bo\MeatController; +use App\Http\Controllers\Bo\NewsCategoryController; use App\Http\Controllers\Bo\NewsCorporateController; use App\Http\Controllers\Bo\OfferController; use App\Http\Controllers\Bo\ProductController; @@ -430,6 +431,18 @@ Route::middleware(['throttle:web', 'admin-secure'])->prefix('bo')->name('bo.')-> 'duplicate' ])->name('news_corporates.duplicate'); + // * NEWS CATEGORIES. + Route::resource('news_categories', NewsCategoryController::class); + Route::patch('/news_categories/{news_category}/change-published', [ + NewsCategoryController::class, 'changePublished' + ])->name('news_categories.change-published'); + Route::patch('/news_categories/{news_category}/change-order/{direction}', [ + NewsCategoryController::class, 'changeOrder' + ])->where('direction', 'up|down')->name('news_categories.change-order'); + Route::get('/news_categories/{news_category}/duplicate', [ + NewsCategoryController::class, 'duplicate' + ])->name('news_categories.duplicate'); + Route::middleware('can:isConceptor')->group(function () { // * ACTIVITY LOGS. Route::resource('activity_logs', ActivityLogController::class)->only(['index', 'show']);