store-manage/database/factories/EmployeeSignLogFactory.php

35 lines
1.1 KiB
PHP

<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\EmployeeSignLog;
use App\Models\Employee;
use App\Enums\SignType;
/**
* @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::class);
return [
'store_id' => $employee->store_id,
'employee_id' => $employee->id,
'sign_type' => $type,
'remarks' => $type == SignType::Outside ? '我在外面的' : '',
'position' => ['province' => '重庆', 'city' => '重庆市', 'address' => '重庆市南川区东城街道办事处东环路三号'],
'time' => $this->faker->dateTimeBetween('-7 days', 'now')
];
}
}