diff --git a/app/Repositories/RoleRepository.php b/app/Repositories/RoleRepository.php index 5977894..5a9dedf 100644 --- a/app/Repositories/RoleRepository.php +++ b/app/Repositories/RoleRepository.php @@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Builder; final readonly class RoleRepository { - final public function __construct( + public function __construct( private CreateSearchInstanceCommand $createSearchInstanceCommand, private BuilderCommand $builderCommand ) { } @@ -36,6 +36,16 @@ final readonly class RoleRepository return $this->createSearchInstanceCommand->execute($query); } + public function getRolesForSelect(array $withExcepts = []): array + { + return Role::query() + ->when($withExcepts, function (Builder $query, array $withExcepts) { + $query->withTrashed()->whereNull('deleted_at')->orWhereIn('id', $withExcepts); + }) + ->pluck('name', 'id') + ->toArray(); + } + public function isExistsCode(string $code, ?int $exceptId = null): bool { return Role::query()