title: Laravel 8 factories
body: <p>Can someone tell me how can I make a factory with relationships etc...</p>
  <p>I have a post table with 2 foreign keys: user_id and category_id
  I need to generate dummy data but I don't know how to do it.</p>
  <p>I have tried to make categories first then to do something with posts and users but did not work.</p>
  <p>PostFactory:</p>
  <pre><code>public function definition()
  {
      $title = $this-&gt;faker-&gt;sentence;
      $slug = Str::slug($title);
      return [
          'title' =&gt; $title,
          'slug' =&gt; $slug,
          'image' =&gt; $this-&gt;faker-&gt;imageUrl(900, 300),
          'content' =&gt; $this-&gt;faker-&gt;text(300),
      ];
  }
  </code></pre>
  <p>CategoryFactory:</p>
  <pre><code>public function definition()
  {
      $category = $this-&gt;faker-&gt;words(2, true);
      $slug = Str::slug($category);
      return [
          'category' =&gt; $category,
          'slug' =&gt; $slug
      ];
  }
  </code></pre>
  <p>And user factory is just default one :)</p>