added hide menu category and group

master
A1Gard 1 day ago
parent eedc1a71e4
commit d2e5dc4387

@ -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{

@ -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;

@ -84,6 +84,7 @@ class PostController extends XController
$post->media()->delete();
$post->addMedia($request->file('image'))
->preservingOriginal() //middle method
->toMediaCollection(); //finishing method
}

@ -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(){

@ -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();
});

@ -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();
});

@ -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 engines 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.
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.

@ -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.
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.

@ -117,7 +117,7 @@
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
placeholder="{{__('Category slug')}}" value="{{old('slug',$item->slug??null)}}"/>
</div>
<div class="col-md-12 mt-3">
<div class="col-md-9 mt-3">
<div class="form-group">
<label for="subtitle">
{{__('Subtitle')}}
@ -128,6 +128,16 @@
value="{{old('subtitle',$item->subtitle??null)}}"/>
</div>
</div>
<div class="col-md-3 mt-4">
<div class="form-group mt-4">
<div class="form-check form-switch">
<input class="form-check-input" name="hide" @if (old('hide',$item->hide??0) != 0)
checked
@endif type="checkbox" id="hide">
<label class="form-check-label" for="hide">{{__('Hide in menu')}}</label>
</div>
</div>
</div>
<div class="col-md-3 mt-3">
<label for="parent">
{{__('Group Parent')}}

@ -95,7 +95,7 @@
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
placeholder="{{__('Group slug')}}" value="{{old('slug',$item->slug??null)}}"/>
</div>
<div class="col-md-12 mt-3">
<div class="col-md-9 mt-3">
<div class="form-group">
<label for="subtitle">
{{__('Subtitle')}}
@ -106,6 +106,17 @@
value="{{old('subtitle',$item->subtitle??null)}}"/>
</div>
</div>
<div class="col-md-3 mt-4">
<div class="form-group mt-4">
<div class="form-check form-switch">
<input class="form-check-input" name="hide" @if (old('hide',$item->hide??0) != 0)
checked
@endif type="checkbox" id="hide">
<label class="form-check-label" for="hide">{{__('Hide in menu')}}</label>
</div>
</div>
</div>
<div class="col-md-4 mt-3">
<label for="parent">
{{__('Group Parent')}}

@ -32,7 +32,7 @@
</li>
@endforeach
@else
@foreach($item->dest->children as $itm)
@foreach($item->dest->children()->where('hide',false)->get() as $itm)
<li>
<a href="{{$itm->webUrl()}}">
{{$itm->name}}
@ -51,7 +51,7 @@
<li>
<a href="{{$itm->webUrl()}}">
{{\Illuminate\Support\Str::limit($itm->title,25)}}
{{\Illuminate\Support\Str::limit(($itm->title),25)}}
</a>
</li>
@endforeach

@ -96,9 +96,9 @@
@switch($item->menuable_type)
@case(\App\Models\Group::class)
@case(\App\Models\Category::class)
@if($item->dest->children()->count() > 0)
@if($item->dest->children()->where('hide',false)->count() > 0)
<ul class="sub-menu-item">
@foreach($item->dest->children as $itm)
@foreach($item->dest->children()->where('hide',false)->get() as $itm)
<li>
<a href="{{$itm->webUrl()}}">
{{$itm->name}}

Loading…
Cancel
Save