*/ private Builder $builder; /** * @param Builder $builder */ public function __construct(Builder $builder) { $this->builder = $builder; } public function addEndFilter(?string $dateTime): self { if ($dateTime === null) { return $this; } $this->builder->where('start', '<', Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $dateTime, 'UTC')); return $this; } public function addStartFilter(?string $dateTime): self { if ($dateTime === null) { return $this; } $this->builder->where('start', '>', Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $dateTime, 'UTC')); return $this; } public function addActiveFilter(?string $active): self { if ($active === null) { return $this; } if ($active === 'true') { $this->builder->whereNull('end'); } if ($active === 'false') { $this->builder->whereNotNull('end'); } return $this; } public function addMemberIdFilter(?Member $member): self { if ($member === null) { return $this; } $this->builder->where('member_id', $member->getKey()); return $this; } /** * @param array|null $memberIds */ public function addMemberIdsFilter(?array $memberIds): self { if ($memberIds === null) { return $this; } $this->builder->whereIn('member_id', $memberIds); return $this; } public function addBillableFilter(?string $billable): self { if ($billable === null) { return $this; } if ($billable === 'true') { $this->builder->where('billable', '=', true); } elseif ($billable === 'false') { $this->builder->where('billable', '=', false); } else { Log::warning('Invalid billable filter value', ['value' => $billable]); } return $this; } /** * @param array|null $clientIds */ public function addClientIdsFilter(?array $clientIds): self { if ($clientIds === null) { return $this; } $this->builder->whereIn('client_id', $clientIds); return $this; } /** * @param array|null $projectIds */ public function addProjectIdsFilter(?array $projectIds): self { if ($projectIds === null) { return $this; } $this->builder->whereIn('project_id', $projectIds); return $this; } /** * @param array|null $tagIds */ public function addTagIdsFilter(?array $tagIds): self { if ($tagIds === null) { return $this; } $this->builder->whereJsonContains('tags', $tagIds); return $this; } /** * @param array|null $taskIds */ public function addTaskIdsFilter(?array $taskIds): self { if ($taskIds === null) { return $this; } $this->builder->whereIn('task_id', $taskIds); return $this; } /** * @return Builder */ public function get(): Builder { return $this->builder; } }