39 lines
933 B
PHP
39 lines
933 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Models\UserDish;
|
||
|
|
use App\Models\UserDishRecurrence;
|
||
|
|
use DishPlanner\UserDish\Interfaces\RecurrenceInterface;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @extends Factory<UserDishRecurrence>
|
||
|
|
*/
|
||
|
|
class UserDishRecurrenceFactory extends Factory
|
||
|
|
{
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'user_dish_id' => null,
|
||
|
|
'recurrence_id' => null,
|
||
|
|
'recurrence_type' => null,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function userDish(UserDish $userDish): self
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'user_dish_id' => $userDish->id,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function recurrence(RecurrenceInterface $recurrence): self
|
||
|
|
{
|
||
|
|
return $this->state(fn (array $attributes) => [
|
||
|
|
'recurrence_id' => $recurrence->id,
|
||
|
|
'recurrence_type' => $recurrence::class,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|