added menu to setting

added menu seeder
pull/44/head
A1Gard 5 months ago
parent 89cafad7c4
commit 247b490185

@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\SettingSaveRequest;
use App\Models\Category;
use App\Models\Group;
use App\Models\Menu;
use App\Models\Setting;
use Illuminate\Http\Request;
@ -20,9 +21,10 @@ class SettingController extends Controller
$settings = Setting::where('active', 1)
->orderBy('section')->get(); //ESH// just active setting`s show
$cats = Category::all(['id','name']);
$menus = Menu::all(['id','name']);
$groups = Group::all(['id','name']);
return view('admin.commons.setting',
compact('settings', 'cats','groups'));
compact('settings', 'cats','groups','menus'));
}
/**

@ -13,7 +13,7 @@ class Setting extends Model
public $translatable = ['value'];
public static $settingTypes = ['TEXT','NUMBER', 'LONGTEXT', 'CODE', 'EDITOR',
'CATEGORY', 'GROUP', 'CHECKBOX', 'FILE', 'COLOR','SELECT'];
'CATEGORY', 'GROUP', 'CHECKBOX', 'FILE', 'COLOR','SELECT','MENU'];
public function getData(){
return json_decode($this->data,true);

@ -2,6 +2,7 @@
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@ -17,7 +18,7 @@ class MenuFactory extends Factory
public function definition(): array
{
return [
//
'user_id' => User::first()->id,
];
}
}

@ -2,6 +2,8 @@
namespace Database\Seeders;
use App\Models\Group;
use App\Models\Menu;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@ -13,5 +15,34 @@ class MenuSeeder extends Seeder
public function run(): void
{
//
Menu::factory(['name' => 'main-menu'])->create();
Menu::first()->items()->createMany([
[
'title' => "Home",
'meta' => '/',
'user_id' => 1,
'kind'=>'direct',
],
[
'title' => "News",
'menuable_id' => 1,
'menuable_type' => Group::class,
'user_id' => 1,
'kind'=>'direct',
],
[
'title' => "Contact",
'meta' => '/contact-us',
'user_id' => 1,
'kind'=>'direct',
],
[
'title' => "About",
'meta' => '/about-us',
'user_id' => 1,
'kind'=>'direct',
],
]);
}
}

@ -56,6 +56,18 @@
xvalue='{{old($setting->key,$setting->value??null)}}'
:close-on-Select="true"></searchable-select>
@break
@case('MENU')
<searchable-select
@error('category_id') :err="true" @enderror
:items='@json($menus)'
title-field="name"
value-field="id"
xid="{{$setting->key}}"
xname="{{$setting->key}}"
@error('category_id') :err="true" @enderror
xvalue='{{old($setting->key,$setting->value??null)}}'
:close-on-Select="true"></searchable-select>
@break
@case('COLOR')
<br>
<input type="color" id="{{$setting->key}}"

Loading…
Cancel
Save