You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.3 KiB

<?php
namespace Database\Factories;
use App\Models\Visit;
use App\Models\Department;
use App\Models\Admin;
use App\Models\VisitArea;
use App\Models\VisitTime;
use Illuminate\Database\Eloquent\Factories\Factory;
class VisitFactory extends Factory
{
protected $model = Visit::class;
public function definition()
{
return [
'name' => $this->faker->name,
'mobile' => $this->faker->phoneNumber,
'idcard' => $this->faker->numerify('11010119########'),
'type' => $this->faker->randomElement([Visit::TYPE_VISITOR, Visit::TYPE_VISITOR_CAR, Visit::TYPE_LOGISTICS_CAR]),
'date' => $this->faker->date(),
'start_date' => $this->faker->date(),
'end_date' => $this->faker->date(),
'start_time' => $this->faker->time(),
'end_time' => $this->faker->time(),
'accept_department_id' => Department::factory(),
'accept_admin_id' => Admin::factory(),
'visit_area_id' => VisitArea::factory(),
'visit_time_id' => VisitTime::factory(),
'audit_status' => $this->faker->randomElement([
Visit::AUDIT_STATUS_PENDING_STUDY,
Visit::AUDIT_STATUS_PENDING,
Visit::AUDIT_STATUS_APPROVED,
Visit::AUDIT_STATUS_REJECTED,
Visit::AUDIT_STATUS_ENTERED,
Visit::AUDIT_STATUS_LEFT,
]),
'credent' => $this->faker->randomElement([Visit::CREDENT_ID_CARD, Visit::CREDENT_PASSPORT]),
'long_time' => $this->faker->boolean,
'need_meal' => $this->faker->boolean,
'meal_type' => $this->faker->randomElement([Visit::MEAL_TYPE_BREAKFAST, Visit::MEAL_TYPE_LUNCH, Visit::MEAL_TYPE_DINNER, Visit::MEAL_TYPE_ALL_DAY]),
'meal_count' => $this->faker->numberBetween(1, 10),
'meal_remark' => $this->faker->sentence,
'meal_preferences' => $this->faker->randomElements(['素食', '荤食', '清真', '无特殊要求'], $this->faker->numberBetween(1, 3)),
'follw_people' => $this->faker->randomElements(['张三', '李四', '王五'], $this->faker->numberBetween(0, 2)),
'cars' => $this->faker->randomElements(['京A12345', '京B67890'], $this->faker->numberBetween(0, 2)),
'file' => $this->faker->randomElements([1, 2, 3, 4, 5], $this->faker->numberBetween(0, 3)),
'vehicle_images' => $this->faker->randomElements([1, 2, 3, 4, 5], $this->faker->numberBetween(0, 3)),
'accept_admin_sign' => $this->faker->numberBetween(1, 10),
'remark' => $this->faker->sentence,
'work_start_time' => $this->faker->date(),
'work_end_time' => $this->faker->date(),
'car_no' => $this->faker->bothify('京A#####'),
'person_no' => $this->faker->bothify('P####'),
];
}
public function visitor()
{
return $this->state(function (array $attributes) {
return [
'type' => Visit::TYPE_VISITOR,
];
});
}
public function visitorCar()
{
return $this->state(function (array $attributes) {
return [
'type' => Visit::TYPE_VISITOR_CAR,
];
});
}
public function logisticsCar()
{
return $this->state(function (array $attributes) {
return [
'type' => Visit::TYPE_LOGISTICS_CAR,
];
});
}
public function pending()
{
return $this->state(function (array $attributes) {
return [
'audit_status' => Visit::AUDIT_STATUS_PENDING,
];
});
}
public function approved()
{
return $this->state(function (array $attributes) {
return [
'audit_status' => Visit::AUDIT_STATUS_APPROVED,
];
});
}
public function entered()
{
return $this->state(function (array $attributes) {
return [
'audit_status' => Visit::AUDIT_STATUS_ENTERED,
];
});
}
public function left()
{
return $this->state(function (array $attributes) {
return [
'audit_status' => Visit::AUDIT_STATUS_LEFT,
];
});
}
}