2021-06-29 00:27:57 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-06-29 00:27:57 +02:00
|
|
|
namespace Database\Factories\Engelsystem\Models\User;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Engelsystem\Models\User\State;
|
2023-10-24 23:00:04 +02:00
|
|
|
use Engelsystem\Models\User\User;
|
2021-06-29 00:27:57 +02:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
class StateFactory extends Factory
|
|
|
|
{
|
|
|
|
/** @var string */
|
2022-12-15 19:50:56 +01:00
|
|
|
protected $model = State::class; // phpcs:ignore
|
2021-06-29 00:27:57 +02:00
|
|
|
|
2022-12-14 19:15:20 +01:00
|
|
|
public function definition(): array
|
2021-06-29 00:27:57 +02:00
|
|
|
{
|
|
|
|
$arrival = $this->faker->optional()->dateTimeThisMonth();
|
|
|
|
|
|
|
|
return [
|
2023-10-24 23:00:04 +02:00
|
|
|
'user_id' => User::factory(),
|
2022-12-25 11:59:45 +01:00
|
|
|
'arrived' => (bool) $arrival,
|
2021-06-29 00:27:57 +02:00
|
|
|
'arrival_date' => $arrival ? Carbon::instance($arrival) : null,
|
2023-11-16 21:27:23 +01:00
|
|
|
'user_info' => $this->faker->optional(.1)->text(),
|
2021-06-29 00:27:57 +02:00
|
|
|
'active' => $this->faker->boolean(.3),
|
|
|
|
'force_active' => $this->faker->boolean(.1),
|
2024-04-10 18:29:12 +02:00
|
|
|
'got_goodie' => $this->faker->boolean(),
|
2021-06-29 00:27:57 +02:00
|
|
|
'got_voucher' => $this->faker->numberBetween(0, 10),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate that the user is arrived
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function arrived(): self
|
2021-06-29 00:27:57 +02:00
|
|
|
{
|
|
|
|
return $this->state(
|
|
|
|
function (array $attributes) {
|
|
|
|
return [
|
|
|
|
'arrived' => true,
|
|
|
|
'arrival_date' => Carbon::instance($this->faker->dateTimeThisMonth()),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|