title: how to create relationship in laravel by model id and model types
body: <p><em>I have a table that is associated with one, using their id and id table type</em></p>
  
  <p>table 1</p>
  
  <p><em>id,
  type_id,
  type,
  count, 
  crteated_at, 
  updated_at</em></p>
  
  <p>other tables</p>
  
  <p><em>id name, ....... crteated_at updated_at</em></p>
  
  <p>model type ids </p>
  
  <p>model2 = type_id = 2;
  model3 = type_id = 3;</p>
  
  <blockquote>
    <p>In model 1 </p>
  </blockquote>
  
  <pre><code>public function model2()
  {
    return $this-&gt;belongsTo(model2::class, 'type_id', 'id');
  }
  
  public function model3()
  {
    return $this-&gt;belongsTo(model3::class, 'type_id', 'id');
  }
  </code></pre>