File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ public function configure()
2929 $ this ->setDescription ('HyperfCms 项目初始化 ' );
3030 }
3131
32-
32+ /**
33+ * 命令执行方法
34+ */
3335 public function handle ()
3436 {
3537 //初始化添加一个默认用户以及一个超级管理员角色
@@ -46,7 +48,7 @@ public function handle()
4648 $ user ->mobile = '1800000000 ' ;
4749 $ user ->sex = User::SEX_BY_MALE ;
4850 $ user ->email = 'admin@admin.com ' ;
49- $ user ->avatar = 'http://landlord-res.oss-cn-shenzhen.aliyuncs.com/admin_face/face ' . rand (1 ,10 ) .'.png ' ;
51+ $ user ->avatar = 'http://landlord-res.oss-cn-shenzhen.aliyuncs.com/admin_face/face ' . rand (1 , 10 ) .'.png ' ;
5052 $ user ->save ();
5153 $ super_role = [
5254 'name ' => 'super_admin ' ,
@@ -64,6 +66,13 @@ public function handle()
6466 $ super_role = Role::create ($ super_role );
6567 $ default_role = Role::create ($ default_role );
6668
69+ //创建权限
70+ $ permissionList = config ('permissionData.permission_list ' );
71+ foreach ($ permissionList as $ permission ) {
72+ if (empty (Permission::query ()->find ($ permission ['id ' ]))) Permission::query ()->insert ($ permission );
73+ $ this ->line ('添加权限成功---------------------------- ' . $ permission ['display_name ' ]);
74+ }
75+
6776 //添加默认角色到默认用户
6877 $ user ->assignRole ($ super_role ->name );
6978 // 通过内置方法 line 在 Console 输出 Hello Hyperf.
You can’t perform that action at this time.
0 commit comments