title: Laravel Multi BelongsTo RelationShip Merge with Eager Loading
body: <p>Laravel version:7.0</p>
  <p><code>reviews</code> table (Model - Review) has <code>id</code>, <code>product_type</code>, <code>product_id</code>, <code>rating</code> columns.</p>
  <p><code>product_type</code> can be <code>service</code>, <code>plugin</code>, <code>module</code> and each value has own model <code>App\Service</code>, <code>App\Plugin</code>, <code>App\Module</code>.  I could put <code>model names</code> directly in <code>product_type</code> but I prefer to use those values.
  Here is <code>Review</code> model relationship.</p>
  <pre><code>public function plugin()
  {
     return $this-&gt;belongsTo(Plugin::class, &quot;product_id&quot;)-&gt;withDefault();
  }
  public function module()
  {
     return $this-&gt;belongsTo(Module::class, &quot;product_id&quot;)-&gt;withDefault();
  }
  public function service()
  {
     return $this-&gt;belongsTo(Service::class, &quot;product_id&quot;)-&gt;withDefault();
  }
  
  public function getItem()
  {
     if($this-&gt;product_type=='module')
     {
        return $this-&gt;module;
     }elseif($this-&gt;product_type=='service')
     {
        return $this-&gt;service;
     }else {
        return $this-&gt;plugin;
     }
  }
  </code></pre>
  <p>Now I want to get them with eager loading in Review Model as following:</p>
  <p><code>$reviews  = Review::with(&quot;getItem&quot;)-&gt;get();</code></p>
  <p>Without Eager loading, I could use <code>$review-&gt;getItem()-&gt;name</code> // this returns name of product.</p>
  <p>How can I get them with eager loading?</p>