Added filters to time-entries.index endpoint

This commit is contained in:
Constantin Graf
2024-02-27 12:05:18 +01:00
parent 9c5a238dda
commit 8b85f50e22
11 changed files with 538 additions and 349 deletions

View File

@@ -10,6 +10,7 @@ use App\Models\Tag;
use App\Models\Task;
use App\Models\TimeEntry;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -49,6 +50,27 @@ class TimeEntryFactory extends Factory
});
}
public function startBetween(Carbon $rangeStart, Carbon $rangeEnd): self
{
$start = $this->faker->dateTimeBetween($rangeStart, $rangeEnd);
return $this->state(function (array $attributes) use ($start): array {
return [
'start' => $start,
'end' => $this->faker->dateTimeBetween($start, 'now'),
];
});
}
public function active(): self
{
return $this->state(function (array $attributes): array {
return [
'end' => null,
];
});
}
public function forUser(User $user): self
{
return $this->state(function (array $attributes) use ($user) {