where('id', $id)->first(); } public function getUserByEmail(string $email): ?User { return User::query()->where('email', Str::lower($email))->first(); } public function getUsers(UserBuilderDto $userBuilderDto, array $with = []): Search { $query = $this->builderCommand->execute( query: User::query()->with($with), userBuilderDto: $userBuilderDto ); return $this->createSearchInstanceCommand->execute($query); } public function isExistsEmail(string $email, ?int $exceptId = null): bool { return User::query() ->where('email', Str::lower($email)) ->when($exceptId, function (Builder $query, int $exceptId) { $query->where('id', '!=', $exceptId); }) ->withTrashed() ->exists(); } }