generated from liutk/owl-admin-base
80 lines
4.1 KiB
PHP
80 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Slowlyo\OwlAdmin\Models\AdminMenu;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
use Throwable;
|
|
|
|
class AdminMenuSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
//
|
|
$menus = [
|
|
['title' => 'index', 'icon' => 'line-md:home-twotone-alt', 'url' => '/index', 'is_home'=>1, 'order'=>1],
|
|
['title' => 'admin_system', 'icon' => 'material-symbols:settings-outline', 'url' => '/system', 'order'=>2,
|
|
'children' => [
|
|
['title' => 'admin_users', 'icon' => 'ph:user-gear', 'url' => '/system/admin_users', 'order'=>1],
|
|
['title' => 'admin_roles', 'icon' => 'carbon:user-role', 'url' => '/system/admin_roles', 'order'=>2],
|
|
// ['title' => 'admin_permission', 'icon' => 'carbon:user-role', 'url' => '/system/admin_permissions', 'order'=>3],
|
|
// ['title' => 'admin_menu', 'icon' => 'fluent-mdl2:permissions', 'url' => '/system/admin_menus', 'order'=>4],
|
|
['title' => 'admin_setting', 'icon' => 'akar-icons:settings-horizontal', 'url' => '/system/settings', 'order'=>5],
|
|
],
|
|
],
|
|
['title' => 'data_content', 'icon' => 'ph:codesandbox-logo-light', 'url' => '', 'order'=>3,
|
|
'children' =>[
|
|
//财务报表类型,档案类型,部门管理,地区类型,社别管理,小区管理,楼栋管理,户籍类型,民族管理,政治面貌,文化程度,机构管理,口头纠纷类型,卫生检查类型,图书类型,企业地区管理,收支情况类型,福利类型,工种管理
|
|
['title' => 'financial_cate', 'icon' => 'tabler:zoom-money', 'url' => '/financial_cate?parent_name=financial_cate&has_owner=0', 'order'=>0],//财务报表类型
|
|
['title' => 'file_cate', 'icon' => 'carbon:document-unknown', 'url' => '/file_cate?parent_name=file_cate&has_owner=0', 'order'=>1],//档案类型
|
|
['title' => 'department', 'icon' => 'mingcute:department-line', 'url' => '/department?parent_name=department&has_owner=0', 'order'=>2],//部门管理
|
|
['title' => 'area_cate', 'icon' => 'majesticons:map-marker-area-line', 'url' => '/area_cate?parent_name=area_cate&has_owner=0', 'order'=>3],//地区类型
|
|
['title' => 'organized_body', 'icon' => 'ic:baseline-people-outline', 'url' => '/organized_body?parent_name=organized_body&has_owner=0', 'order'=>4],//社别管理
|
|
['title' => 'housing_estate', 'icon' => 'bx:building-house', 'url' => '/housing_estate?parent_name=housing_estate&has_owner=0', 'order'=>5],//小区管理
|
|
['title' => 'building', 'icon' => 'fe:building', 'url' => '/building', 'order'=>6],//楼栋管理
|
|
|
|
// ['title'=>'articles', 'icon'=>'ic:outline-article','url'=>'/articles', 'order'=>1],
|
|
// ['title'=>'ads', 'icon'=>'lets-icons:img-box','url'=>'/ads', 'order'=>2],
|
|
]
|
|
]
|
|
];
|
|
DB::table('admin_menus')->truncate();
|
|
try {
|
|
DB::begintransaction();
|
|
$this->createMenus($menus);
|
|
DB::commit();
|
|
} catch (Throwable $th) {
|
|
DB::rollBack();
|
|
report($th);
|
|
}
|
|
}
|
|
|
|
public function createMenus(array $menus, $pid = 0)
|
|
{
|
|
foreach ($menus as $menu) {
|
|
$mm = AdminMenu::create([
|
|
'title' => $menu['title'],
|
|
'icon' => $menu['icon'],
|
|
'url' => $menu['url'],
|
|
'parent_id' => $pid,
|
|
'url_type' => $menu['url_type'] ?? 1,
|
|
'visible' => $menu['visible'] ?? 1,
|
|
'is_home' => $menu['is_home'] ?? 0,
|
|
'order' => $menu['order'] ?? 0,
|
|
'is_full' => 0,
|
|
]);
|
|
|
|
if (isset($menu['children'])) {
|
|
$this->createMenus($menu['children'], $mm->id);
|
|
}
|
|
}
|
|
}
|
|
}
|