'haoxiaoyun/setting'])->find(); if ($np == null) { $p = Permission::where([['auth_name', '=', '企业管理']])->find(); $np = Permission::create([ 'pid' => $p->id, 'auth_name' => '外呼设置', 'uri' => 'haoxiaoyun/setting', 'relation' => 'haoxiaoyun/setting,haoxiaoyun/settingSave,haoxiaoyun/balence', 'is_menu' => 1 ]); } // 复制超级管理员权限 $s = Grant::find(1); $pm = (array)$s->permission; $pm[] = $np->id; $c = [643]; foreach ($c as $root_id) { $super = Grant::where(['type' => 'm', 'root_id' => $root_id])->find(); if($super){ $spm = (array)$super->permission; $spm[] = $np->id; $super->permission = $spm; $super->save(); continue; } $g = Grant::create([ 'name' => '超级管理员', 'permission' => $pm, 'type' => 'm', 'root_id' => $root_id ]); Employee::where(['root_id' => $root_id, 'top_one' => 1])->update([ 'grant_id' => $g->id ]); } } }