title: Laravel resource relation query
body: <p>I have a properly working function in controller:</p>
  <pre><code>public function user_p()
  {
      $id = Auth::user()-&gt;id;
      return Inertia::render('User_p',[ 'user_p' =&gt; Model::where('id', $id)-&gt;with([ 'relation_one.relation_two' =&gt; function ($query) use ($id) {$query-&gt;where('user_p', $id);}])-&gt;first()]);
  }
  </code></pre>
  <p>how to correctly create Resource with the same as above ?</p>
  <pre><code>public function toArray($request)
  {
      
      return [
          'id' =&gt; $this-&gt;id,
          'relation' =&gt; $this-&gt;relation_one.relation_two =&gt; function ($query) {$query-&gt;where('user_p', $request-&gt;user()-&gt;id);}
      ];
  }
  </code></pre>
  <p>did not work ... error: 'Illegal offset type'</p>