You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
582 B
26 lines
582 B
<?php
|
|
|
|
namespace App\Domains\Identity\Actions\AccessControl;
|
|
|
|
use App\Domains\Identity\DTOs\AccessControl\CreateRoleDTO;
|
|
use App\Domains\Identity\Models\Role;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Throwable;
|
|
|
|
class CreateSystemRole
|
|
{
|
|
/**
|
|
* @throws Throwable
|
|
*/
|
|
public function execute(CreateRoleDTO $dto): bool
|
|
{
|
|
return DB::transaction(function () use ($dto) {
|
|
$role = Role::create([
|
|
'name' => $dto->name,
|
|
]);
|
|
$role->syncPermissions($dto->permissions);
|
|
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
|