title: How to joining Table in Laravel 5.8
body: <p>I have 2 table users and data . </p>
  
  <blockquote>
    <p>in users table have :</p>
  </blockquote>
  
  <p>id | name |email | etc </p>
  
  <blockquote>
    <p>in data table have :</p>
  </blockquote>
  
  <p>id | user_id | no_data | etc </p>
  
  <p>i create model Data like this </p>
  
  <pre><code>public function users()
  {
      return $this-&gt;HasMany(\App\User::class ,'id');
  }
  </code></pre>
  
  <p>my Controller :</p>
  
  <pre><code>public function pns()
  {
      $data = Data::get();
  
      //DB::table('data')
          //-&gt;join('users','data.user_id','=','users.id')
          //-&gt;where(['user' =&gt; 'something', 'otherThing' =&gt; 
           // 'otherThing'])
          //-&gt;get(); // i trying to join this table but still error 
  
  
      return view('admin.data',['data' =&gt; $data]);
  }
  </code></pre>
  
  <p>now i want to show view data in table : </p>
  
  <p>on my view blade :</p>
  
  <pre><code> &lt;th&gt;No &lt;/th&gt;
   &lt;th&gt;id &lt;/th&gt;
   &lt;th&gt;Name &lt;/th&gt;
   &lt;th&gt;email &lt;/th&gt;
  
  
    @php
    $no=0;
    @endphp
    @foreach ($data as $i)
    &lt;tr&gt;
     &lt;td class=" "&gt;{{ ++$no }}&lt;/td&gt;
     &lt;td class=" "&gt;{{ $i-&gt;user_id}}&lt;/td&gt;
     &lt;td class=" "&gt;{{ $i-&gt;users-&gt;name}}&lt;/td&gt;
     &lt;td class=" "&gt;{{ $i-&gt;email}}&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>
  
  <p>this user_id is showed ,but this 'name' is cant showed and get error :</p>
  
  <p>Property [name] does not exist on this collection instance.</p>
  
  <p>edited my dd($data) </p>
  
  <pre><code>#attributes: array:18 [▼
      "id" =&gt; 1
      "user_id" =&gt; 6
      "email" =&gt; 'q@gmail.com'
      //etc
      "created_at" =&gt; "2019-06-18 17:27:54"
      "updated_at" =&gt; "2019-06-18 17:27:54"
    ]
  </code></pre>