Laravel Undefined property: stdClass::$id error
<p>I am very much new to laravel, and even some minor errors scares me..i am fetching the data from a table with name 'student' but while i do that i am getting an error as </p>

<blockquote>
  <p>Undefined property: stdClass::$id</p>
</blockquote>

<p>it would be great if i get some help here..thank you</p>

<p><strong>StudViewController.php</strong></p>

<pre><code>&lt;?php
namespace App\Http\Controllers;
use DB;
use App\Http\Controllers\Controller;

class StudViewController extends Controller
{
    //
    public function index(){
      $users = DB::select('select * from student');
      return view('stud_view',['users'=&gt;$users]);
   }
}
</code></pre>

<p><strong>stud_view.blade.php</strong></p>

<pre><code>@extends('layouts.app')

@section('content')
&lt;div class="container"&gt;
    &lt;div class="row"&gt;
&lt;table border = 1&gt;
         &lt;tr&gt;
            &lt;td&gt;ID&lt;/td&gt;
            &lt;td&gt;Name&lt;/td&gt;
         &lt;/tr&gt;
         @foreach ($users as $user)
         &lt;tr&gt;
            &lt;td&gt;{{ $user-&gt;id }}&lt;/td&gt;
            &lt;td&gt;{{ $user-&gt;name }}&lt;/td&gt;
         &lt;/tr&gt;
         @endforeach
      &lt;/table&gt;
    &lt;/div&gt;
&lt;/div&gt;
@endsection
</code></pre>

<p><strong>routes.php</strong></p>

<pre><code>Route::get('view-records','StudViewController@index');
</code></pre>