54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Schedule;
|
|
use App\Models\ScheduledUserDish;
|
|
use App\Models\User;
|
|
use App\Models\UserDish;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<ScheduledUserDish>
|
|
*/
|
|
class ScheduledUserDishFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'schedule_id' => null,
|
|
'user_id' => null,
|
|
'user_dish_id' => null,
|
|
'is_skipped' => false,
|
|
];
|
|
}
|
|
|
|
public function schedule(Schedule $schedule): self
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'schedule_id' => $schedule->id,
|
|
]);
|
|
}
|
|
|
|
public function user(User $user): self
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'user_id' => $user->id,
|
|
]);
|
|
}
|
|
|
|
public function userDish(UserDish $userDish): self
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'user_dish_id' => $userDish->id,
|
|
'user_id' => $userDish->user_id,
|
|
]);
|
|
}
|
|
|
|
public function skipped(): self
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_skipped' => true,
|
|
]);
|
|
}
|
|
}
|