erp/app/Console/Commands/UpdateSuperPermissions.php

48 lines
987 B
PHP
Raw Normal View History

2022-08-01 05:07:38 +08:00
<?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('更新成功');
}
}