mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 14:40:44 +00:00
48 lines
987 B
PHP
48 lines
987 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands;
|
||
|
|
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
use Spatie\Permission\Models\Permission;
|
||
|
|
use Spatie\Permission\Models\Role;
|
||
|
|
|
||
|
|
class UpdateSuperPermissions extends Command
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The name and signature of the console command.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $signature = 'update:super_admin_permissions';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The console command description.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $description = '更新超级管理员权限';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create a new command instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
parent::__construct();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the console command.
|
||
|
|
*
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
$role = Role::query()->where('name', '超级管理员')->find(1);
|
||
|
|
$permissions = Permission::query()->get();
|
||
|
|
$role->syncPermissions($permissions);
|
||
|
|
$this->info('更新成功');
|
||
|
|
}
|
||
|
|
}
|