title: how to use laravel resources for relationship both side
body: <p>I have a "many to many" relationship</p>
  
  <p><code>category belongstomany jobs</code> <br>
  and <br>
  <code>job belongstomany categories</code></p>
  
  <p>I have two resources: <code>CategoryResources</code> and <code>JobResources</code></p>
  
  <p>They are like this:</p>
  
  <p>CategoryResources</p>
  
  <pre><code>'name' =&gt; $this-&gt;name,
  'slug' =&gt; $this-&gt;slug,
  'icon' =&gt; $this-&gt;icon,
  'created_at' =&gt; $this-&gt;created_at-&gt;diffForHumans(),
  'jobs' =&gt; JobResources::collection($this-&gt;jobs)
  </code></pre>
  
  <p>JobResources</p>
  
  <pre><code>'id' =&gt; $this-&gt;id,
  'title' =&gt; $this-&gt;title,
  'slug' =&gt; $this-&gt;slug,
  'description' =&gt; $this-&gt;description,
  'type' =&gt; new TypeResources($this-&gt;type),
  'categories' =&gt; CategoryResources::collection($this-&gt;categories)
  'created_at' =&gt; $this-&gt;created_at-&gt;diffForHumans()
  </code></pre>
  
  <p>The problem is that it's taking infinite time to fetch the data. How could I prevent this?</p>
  
  <p>As an alternative I made different resources like <code>JobReverseResource</code>, but its wrong.</p>
  
  <p>Thanks</p>