title: Laravel Relationship Array with integer column
body: <p><strong>Category Table</strong></p>
  
  <p><a href="https://i.stack.imgur.com/K96Tj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K96Tj.png" alt="enter image description here"></a></p>
  
  <p><strong>Product Table</strong></p>
  
  <p><a href="https://i.stack.imgur.com/TpRIO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TpRIO.png" alt="enter image description here"></a></p>
  
  <p><strong>I want to be create relationship with category tables ->id with Product table category_id suggest any idea for this relationship</strong>
  Array with integer column relationship</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>Products::with('category')-&gt;get();
  </code></pre>
  
  <p><strong>Product Model</strong></p>
  
  <pre><code>public function category() {
      return $this-&gt;hasMany(App\Models\Categories::class, 'id', 'category_id');
  }
  </code></pre>
  
  <p><strong>Category Model</strong></p>
  
  <pre><code>public function product() {
      return $this-&gt;belongsTo(Products::class,'category_id', 'id');
  }
  </code></pre>