0
  • Board has many posts.
  • User has many posts.

I want to make dummy posts. I created dummy users and boards. What should I fill in board_id and user_id?

class PostFactory extends Factory
{
    /**
     * Define the model's default state.
     * @return array<string, mixed>
     */
    public function definition()
    {
        return [
            'board_id' => ,
            'user_id' =>, 
            'title' => $this->faker->, 
            'content' => $this->faker->,
        ];
    }
}
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
rurumita
  • 17
  • 2
  • Are you sure you want a one-to-many relationship? It looks like you're heading for a many-to-many relationship based on your request. – steven7mwesigwa Mar 29 '22 at 00:01
  • @steven7mwesigwa Sorry, the question is a liitle bit confused. But I found solution [here](https://laracasts.com/discuss/channels/laravel/factory-with-a-foreign-key) – rurumita Mar 29 '22 at 00:14

0 Answers0