Hari Hari - 9 months ago 82
PHP Question

Laravel Undefined property: stdClass::$id error

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

Undefined property: stdClass::$id

it would be great if i get some help here..thank you


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'=>$users]);



<div class="container">
<div class="row">
<table border = 1>
@foreach ($users as $user)
<td>{{ $user->id }}</td>
<td>{{ $user->name }}</td>



Answer Source

Try this...

@foreach ($users as $user)
    <td>{{ $user->Id }}</td>
    <td>{{ $user->Name }}</td>