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.

55 lines
1.4 KiB

11 months ago
<?php
namespace Database\Factories;
use App\Models\Study;
use Illuminate\Database\Eloquent\Factories\Factory;
class StudyFactory extends Factory
{
protected $model = Study::class;
public function definition()
{
return [
'name' => $this->faker->sentence(3),
'content' => $this->faker->paragraphs(3, true),
'type' => $this->faker->randomElement([
Study::TYPE_VISITOR,
Study::TYPE_VISITOR_CAR,
Study::TYPE_LOGISTICS_CAR,
]),
'file' => $this->faker->randomElements([1, 2, 3, 4, 5], $this->faker->numberBetween(0, 3)),
'expire_day' => $this->faker->numberBetween(1, 365),
'minute' => $this->faker->numberBetween(10, 120),
'rate' => $this->faker->randomFloat(2, 60, 100),
];
}
public function visitor()
{
return $this->state(function (array $attributes) {
return [
'type' => Study::TYPE_VISITOR,
];
});
}
public function visitorCar()
{
return $this->state(function (array $attributes) {
return [
'type' => Study::TYPE_VISITOR_CAR,
];
});
}
public function logisticsCar()
{
return $this->state(function (array $attributes) {
return [
'type' => Study::TYPE_LOGISTICS_CAR,
];
});
}
}