42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Attendance;
|
|
use App\Models\Employee;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Attendance>
|
|
*/
|
|
class AttendanceFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
$checkInAt = fake()->dateTimeBetween('-30 days', 'now');
|
|
$checkOutAt = (clone $checkInAt)->modify('+'.fake()->numberBetween(4, 9).' hours');
|
|
|
|
return [
|
|
'employee_id' => Employee::factory(),
|
|
'attendance_date' => $checkInAt->format('Y-m-d'),
|
|
'check_in_at' => $checkInAt,
|
|
'check_out_at' => $checkOutAt,
|
|
'check_in_latitude' => fake()->latitude(-7, -6),
|
|
'check_in_longitude' => fake()->longitude(106, 107),
|
|
'check_out_latitude' => fake()->latitude(-7, -6),
|
|
'check_out_longitude' => fake()->longitude(106, 107),
|
|
'work_duration_minutes' => fake()->numberBetween(240, 540),
|
|
];
|
|
}
|
|
|
|
public function checkedInOnly(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'check_out_at' => null,
|
|
'check_out_latitude' => null,
|
|
'check_out_longitude' => null,
|
|
'work_duration_minutes' => null,
|
|
]);
|
|
}
|
|
}
|