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.

64 lines
1.4 KiB

11 months ago
<?php
namespace Database\Factories;
use App\Models\VisitLog;
use App\Models\Visit;
use App\Models\Admin;
use Illuminate\Database\Eloquent\Factories\Factory;
class VisitLogFactory extends Factory
{
protected $model = VisitLog::class;
public function definition()
{
return [
'visit_id' => Visit::factory(),
'admin_id' => Admin::factory(),
'type' => $this->faker->randomElement([
VisitLog::TYPE_ENTER,
VisitLog::TYPE_LEAVE,
VisitLog::TYPE_APPROVE,
VisitLog::TYPE_REJECT,
]),
'remark' => $this->faker->sentence,
];
}
public function enter()
{
return $this->state(function (array $attributes) {
return [
'type' => VisitLog::TYPE_ENTER,
];
});
}
public function leave()
{
return $this->state(function (array $attributes) {
return [
'type' => VisitLog::TYPE_LEAVE,
];
});
}
public function approve()
{
return $this->state(function (array $attributes) {
return [
'type' => VisitLog::TYPE_APPROVE,
];
});
}
public function reject()
{
return $this->state(function (array $attributes) {
return [
'type' => VisitLog::TYPE_REJECT,
];
});
}
}