Added method getRolesForSelect in the RoleRepository.
This commit is contained in:
parent
73d99a0432
commit
9c1ed593b5
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Builder;
|
|||||||
|
|
||||||
final readonly class RoleRepository
|
final readonly class RoleRepository
|
||||||
{
|
{
|
||||||
final public function __construct(
|
public function __construct(
|
||||||
private CreateSearchInstanceCommand $createSearchInstanceCommand,
|
private CreateSearchInstanceCommand $createSearchInstanceCommand,
|
||||||
private BuilderCommand $builderCommand
|
private BuilderCommand $builderCommand
|
||||||
) { }
|
) { }
|
||||||
@ -36,6 +36,16 @@ final readonly class RoleRepository
|
|||||||
return $this->createSearchInstanceCommand->execute($query);
|
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
|
public function isExistsCode(string $code, ?int $exceptId = null): bool
|
||||||
{
|
{
|
||||||
return Role::query()
|
return Role::query()
|
||||||
|
Loading…
Reference in New Issue
Block a user