generated from liutk/owl-admin-base
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\SignTime;
|
|
use App\Enums\SignType;
|
|
use App\Models\Employee;
|
|
use App\Models\EmployeeSignLog;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EmployeeSign>
|
|
*/
|
|
class EmployeeSignLogFactory extends Factory
|
|
{
|
|
protected $model = EmployeeSignLog::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$employee = Employee::where('store_id', '>', 0)->inRandomOrder()->first();
|
|
$type = $this->faker->randomElement([SignType::Normal, SignType::Outside]);
|
|
$time = $this->faker->randomElement(SignTime::class);
|
|
|
|
return [
|
|
'store_id' => $employee->store_id,
|
|
'employee_id' => $employee->id,
|
|
'sign_type' => $type,
|
|
'sign_time' => $time,
|
|
'remarks' => $type == SignType::Outside ? '我在外面的' : '',
|
|
'position' => ['province' => '重庆', 'city' => '重庆市', 'address' => '重庆市南川区东城街道办事处东环路三号'],
|
|
'time' => $this->faker->dateTimeBetween('-7 days', 'now'),
|
|
];
|
|
}
|
|
}
|