<?php

namespace App\Domains\Permission\Commands;

use Illuminate\Console\Command;
use App\Domains\Permission\Services\PermissionService;
use App\Domains\Permission\Repositories\RoleRepository;

class PermissionRootCommand extends Command
{
    protected $signature = 'permission:root';

    protected $description = '修复ROOT权限';

    public function handle()
    {
        $role = app(RoleRepository::class)->where('name', '超级管理员')->first();

        $permissions = app(PermissionService::class)->getPermissions();

        $role->syncPermissions($permissions);

        $this->alert('root permissions fixed.');
    }
}
