370 lines
9.3 KiB
PHP
370 lines
9.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use DB;
|
|
|
|
class AdminPermissionSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
//清空现有权限
|
|
DB::table('admin_permissions')->truncate();
|
|
$json_data = '[
|
|
{
|
|
"name":"Auth management",
|
|
"slug":"auth-management",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":16,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"Users",
|
|
"slug":"users",
|
|
"http_method":"",
|
|
"http_path":"/auth/users*",
|
|
"order":17,
|
|
"parent_id":1
|
|
},
|
|
{
|
|
"name":"Roles",
|
|
"slug":"roles",
|
|
"http_method":"",
|
|
"http_path":"/auth/roles*",
|
|
"order":18,
|
|
"parent_id":1
|
|
},
|
|
{
|
|
"name":"Permissions",
|
|
"slug":"permissions",
|
|
"http_method":"",
|
|
"http_path":"/auth/permissions*",
|
|
"order":19,
|
|
"parent_id":1
|
|
},
|
|
{
|
|
"name":"Menu",
|
|
"slug":"menu",
|
|
"http_method":"",
|
|
"http_path":"/auth/menu*",
|
|
"order":20,
|
|
"parent_id":1
|
|
},
|
|
{
|
|
"name":"Extension",
|
|
"slug":"extension",
|
|
"http_method":"",
|
|
"http_path":"/auth/extensions*",
|
|
"order":21,
|
|
"parent_id":1
|
|
},
|
|
{
|
|
"name":"首页",
|
|
"slug":"index",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":1,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"用户管理",
|
|
"slug":"mini-users",
|
|
"http_method":"",
|
|
"http_path":"/users*",
|
|
"order":2,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"小程序管理",
|
|
"slug":"mini-seting",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":3,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"Banner管理",
|
|
"slug":"banners",
|
|
"http_method":"",
|
|
"http_path":"/banners*",
|
|
"order":4,
|
|
"parent_id":9
|
|
},
|
|
{
|
|
"name":"文章管理",
|
|
"slug":"articles",
|
|
"http_method":"",
|
|
"http_path":"/articles*",
|
|
"order":5,
|
|
"parent_id":9
|
|
},
|
|
{
|
|
"name":"活动管理",
|
|
"slug":"mini-activity",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":6,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"活动配置",
|
|
"slug":"activity-options",
|
|
"http_method":"",
|
|
"http_path":"/activity_options*",
|
|
"order":7,
|
|
"parent_id":12
|
|
},
|
|
{
|
|
"name":"兑换配置",
|
|
"slug":"activity-goods",
|
|
"http_method":"",
|
|
"http_path":"/activity_goods*",
|
|
"order":8,
|
|
"parent_id":12
|
|
},
|
|
{
|
|
"name":"商城管理",
|
|
"slug":"mall",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":9,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"商品管理",
|
|
"slug":"mall-goods",
|
|
"http_method":"",
|
|
"http_path":"/goods*",
|
|
"order":10,
|
|
"parent_id":15
|
|
},
|
|
{
|
|
"name":"分类管理",
|
|
"slug":"mall-goods-category",
|
|
"http_method":"",
|
|
"http_path":"/goods_categories*",
|
|
"order":11,
|
|
"parent_id":15
|
|
},
|
|
{
|
|
"name":"商品类型",
|
|
"slug":"mall-goods-type",
|
|
"http_method":"",
|
|
"http_path":"/goods_types*",
|
|
"order":12,
|
|
"parent_id":15
|
|
},
|
|
{
|
|
"name":"订单管理",
|
|
"slug":"orders",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":13,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"订单列表",
|
|
"slug":"orders-list",
|
|
"http_method":"",
|
|
"http_path":"/orders*",
|
|
"order":14,
|
|
"parent_id":19
|
|
},
|
|
{
|
|
"name":"核销取餐",
|
|
"slug":"orders-pickup",
|
|
"http_method":"",
|
|
"http_path":"/order_pickup*",
|
|
"order":15,
|
|
"parent_id":19
|
|
},
|
|
{
|
|
"name":"接口权限",
|
|
"slug":"api",
|
|
"http_method":"",
|
|
"http_path":"",
|
|
"order":22,
|
|
"parent_id":0
|
|
},
|
|
{
|
|
"name":"商品",
|
|
"slug":"api-goods",
|
|
"http_method":"",
|
|
"http_path":"/api/goods*",
|
|
"order":23,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"商品分类",
|
|
"slug":"api-goods-category",
|
|
"http_method":"",
|
|
"http_path":"/api/goods_categories*",
|
|
"order":24,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"商品类型",
|
|
"slug":"api-goods-type",
|
|
"http_method":"",
|
|
"http_path":"/api/goods_types*",
|
|
"order":25,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"商品属性",
|
|
"slug":"api-goods-attr",
|
|
"http_method":"",
|
|
"http_path":"/api/goods_attrs*",
|
|
"order":26,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"上传图片",
|
|
"slug":"editor-upload-image",
|
|
"http_method":"",
|
|
"http_path":"/upload_image*",
|
|
"order":27,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"类型属性",
|
|
"slug":"api-type-attrs",
|
|
"http_method":"",
|
|
"http_path":"/api/type_attrs",
|
|
"order":28,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"查询订单",
|
|
"slug":"api-orders",
|
|
"http_method":"",
|
|
"http_path":"/api/orders*",
|
|
"order":29,
|
|
"parent_id":22
|
|
},
|
|
{
|
|
"name":"核销订单",
|
|
"slug":"api-pickup-order",
|
|
"http_method":"",
|
|
"http_path":"/pickup_order*",
|
|
"order":30,
|
|
"parent_id":22
|
|
}]';
|
|
|
|
$list = json_decode($json_data);
|
|
|
|
$insert_data = array();
|
|
foreach ($list as $key => $value) {
|
|
$insert_data[] = [
|
|
'name' => $value->name,
|
|
'slug' => $value->slug,
|
|
'http_method' => $value->http_method,
|
|
'http_path' => $value->http_path,
|
|
'order' => $value->order,
|
|
'parent_id'=> $value->parent_id,
|
|
];
|
|
}
|
|
|
|
if(count($insert_data) > 0){
|
|
DB::table('admin_permissions')->insert($insert_data);
|
|
}
|
|
|
|
//插入权限菜单关联
|
|
DB::table('admin_permission_menu')->truncate();
|
|
$json_data = '[
|
|
{
|
|
"permission_id":1,
|
|
"menu_id":2
|
|
},
|
|
{
|
|
"permission_id":2,
|
|
"menu_id":3
|
|
},
|
|
{
|
|
"permission_id":3,
|
|
"menu_id":4
|
|
},
|
|
{
|
|
"permission_id":4,
|
|
"menu_id":5
|
|
},
|
|
{
|
|
"permission_id":5,
|
|
"menu_id":6
|
|
},
|
|
{
|
|
"permission_id":6,
|
|
"menu_id":7
|
|
},
|
|
{
|
|
"permission_id":7,
|
|
"menu_id":1
|
|
},
|
|
{
|
|
"permission_id":8,
|
|
"menu_id":18
|
|
},
|
|
{
|
|
"permission_id":9,
|
|
"menu_id":8
|
|
},
|
|
{
|
|
"permission_id":10,
|
|
"menu_id":9
|
|
},
|
|
{
|
|
"permission_id":11,
|
|
"menu_id":10
|
|
},
|
|
{
|
|
"permission_id":13,
|
|
"menu_id":16
|
|
},
|
|
{
|
|
"permission_id":14,
|
|
"menu_id":17
|
|
},
|
|
{
|
|
"permission_id":15,
|
|
"menu_id":11
|
|
},
|
|
{
|
|
"permission_id":16,
|
|
"menu_id":14
|
|
},
|
|
{
|
|
"permission_id":17,
|
|
"menu_id":12
|
|
},
|
|
{
|
|
"permission_id":18,
|
|
"menu_id":13
|
|
},
|
|
{
|
|
"permission_id":21,
|
|
"menu_id":21
|
|
}]';
|
|
|
|
$list = json_decode($json_data);
|
|
|
|
$insert_data = array();
|
|
foreach ($list as $key => $value) {
|
|
$insert_data[] = [
|
|
'permission_id' => $value->permission_id,
|
|
'menu_id' => $value->menu_id,
|
|
];
|
|
}
|
|
|
|
if(count($insert_data) > 0){
|
|
DB::table('admin_permission_menu')->insert($insert_data);
|
|
}
|
|
}
|
|
}
|