diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php index 0a3886f..11b1819 100644 --- a/app/Http/Controllers/Admin/CategoryController.php +++ b/app/Http/Controllers/Admin/CategoryController.php @@ -60,6 +60,8 @@ class CategoryController extends XController $category->subtitle = $request->input('subtitle'); $category->icon = $request->input('icon'); $category->description = $request->input('description'); + $category->hide = $request->has('hide'); + if ($request->input('parent_id') == ''){ $category->parent_id = null; }else{ diff --git a/app/Http/Controllers/Admin/GroupController.php b/app/Http/Controllers/Admin/GroupController.php index 60d92a6..d495308 100644 --- a/app/Http/Controllers/Admin/GroupController.php +++ b/app/Http/Controllers/Admin/GroupController.php @@ -58,6 +58,7 @@ class GroupController extends XController $group->name = $request->input('name'); $group->subtitle = $request->input('subtitle'); $group->description = $request->input('description'); + $group->hide = $request->has('hide'); if ($request->input('parent_id') == ''){ $group->parent_id = null; diff --git a/app/Http/Controllers/Admin/PostController.php b/app/Http/Controllers/Admin/PostController.php index f851a34..06e3225 100644 --- a/app/Http/Controllers/Admin/PostController.php +++ b/app/Http/Controllers/Admin/PostController.php @@ -84,6 +84,7 @@ class PostController extends XController $post->media()->delete(); $post->addMedia($request->file('image')) ->preservingOriginal() //middle method + ->toMediaCollection(); //finishing method } diff --git a/app/Models/Category.php b/app/Models/Category.php index c77dc82..d55531f 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -96,11 +96,17 @@ class Category extends Model public function published($limit = 10, $order = 'id', $dir = 'DESC') { - return $this->products()->where('status', 1) + return $this->products()->where('status', 1) ->orderBy($order, $dir)->limit($limit)->get([ - DB::raw('name as "title"'), - 'slug' - ]); + 'name', + 'slug', + ])->map(function ($item) { + // Change 'name' to 'title' + $item->title = $item->name; // Add title property + unset($item->name); // Remove the old name property + return $item; // Return the modified item + }); + } public function evaluations(){ diff --git a/database/migrations/2024_05_07_123332_create_groups_table.php b/database/migrations/2024_05_07_123332_create_groups_table.php index 4d62d81..4248a01 100644 --- a/database/migrations/2024_05_07_123332_create_groups_table.php +++ b/database/migrations/2024_05_07_123332_create_groups_table.php @@ -23,6 +23,7 @@ return new class extends Migration $table->unsignedInteger('parent_id')->nullable()->default(null)->index(); $table->json('theme')->nullable(); $table->text('canonical')->nullable(); + $table->boolean('hide')->default(true)->comment('hide in menu as sub group'); $table->softDeletes(); $table->timestamps(); }); diff --git a/database/migrations/2024_05_07_125838_create_categories_table.php b/database/migrations/2024_05_07_125838_create_categories_table.php index 992d28e..c12cddf 100644 --- a/database/migrations/2024_05_07_125838_create_categories_table.php +++ b/database/migrations/2024_05_07_125838_create_categories_table.php @@ -25,6 +25,7 @@ return new class extends Migration $table->unsignedInteger('parent_id')->nullable()->default(null)->index(); $table->json('theme')->nullable(); $table->text('canonical')->nullable(); + $table->boolean('hide')->default(true)->comment('hide in menu as sub category'); $table->softDeletes(); $table->timestamps(); }); diff --git a/docs/5-group.md b/docs/5-group.md index 850f5a9..8b369a7 100644 --- a/docs/5-group.md +++ b/docs/5-group.md @@ -48,5 +48,11 @@ The `Group` model is designed to categorize content in your application. It allo - **Type:** Text (Nullable) - **Description:** This field is used for SEO (Search Engine Optimization) purposes. It helps in directing the search engine’s authority of a group to another page, enhancing the SEO power of that group. This is particularly useful for managing duplicate content. + +### 12. `hide` +- **Type:** Boolean +- **Description:** This field is used to hide the category in the site menu. Essentially, if this option is set to `false`, the group will be displayed as a submenu in the menu. However, +- if it is set to `true`, it will be hidden from display. The default value is `false`. + --- -By utilizing this `Group` model, you can effectively organize your content in a way that is user-friendly and conducive to SEO, providing a better experience for your users. \ No newline at end of file +By utilizing this `Group` model, you can effectively organize your content in a way that is user-friendly and conducive to SEO, providing a better experience for your users. diff --git a/docs/8-category.md b/docs/8-category.md index 00bd7e7..d9c3c14 100644 --- a/docs/8-category.md +++ b/docs/8-category.md @@ -56,5 +56,9 @@ The `Category` model is used to categorize products within your application. Thi - **Type:** Text (Nullable) - **Description:** This field is used for SEO (Search Engine Optimization) purposes. It helps in transferring the search engine authority of the category to another page, enhancing the SEO potential of that category. This is particularly useful for managing duplicate content. +### 14. `hide` +- **Type:** Boolean +- **Description:** This field is used to hide the category in the site menu. Essentially, if this option is set to `false`, the category will be displayed as a submenu in the menu. However, if it is set to `true`, it will be hidden from display. The default value is `false`. + --- -By utilizing this `Category` model, you can effectively organize your product categories in a structured way, enhancing user experience and improving SEO, while offering flexibility with images and icons. \ No newline at end of file +By utilizing this `Category` model, you can effectively organize your product categories in a structured way, enhancing user experience and improving SEO, while offering flexibility with images and icons. diff --git a/resources/views/admin/categories/category-form.blade.php b/resources/views/admin/categories/category-form.blade.php index cee7d33..40f7ead 100644 --- a/resources/views/admin/categories/category-form.blade.php +++ b/resources/views/admin/categories/category-form.blade.php @@ -117,7 +117,7 @@ -