36 lines
700 B
PHP
36 lines
700 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Dish;
|
|
use App\Models\UserDish;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<UserDish>
|
|
*/
|
|
class UserDishFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'dish_id' => null,
|
|
'user_id' => null,
|
|
];
|
|
}
|
|
|
|
public function dish(Dish $dish): self
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'dish_id' => $dish->id,
|
|
]);
|
|
}
|
|
|
|
public function user(User $user): self
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'user_id' => $user->id,
|
|
]);
|
|
}
|
|
}
|