mercredi 30 août 2017

Larevel Cannot use object of type stdClass as array when using Query Builder

Short Version of question:

I received Cannot use object of type stdClass as array when using Query Builder, but works fine with Eloquent. How I solve that issue?

Long Version of question:

When I using method 1 there is a error.

Error : Cannot use object of type stdClass as array (This gives for view foreach start line)

But when I using method 2 there is no error.

I wanted to know why it return error when I using method 2. How I correct it?

Method 01 (In Controller)

$parents = DB::table('stuparents');
$parents = $parents->orderBy('first_name');
$parents = $parents->get();

Method 02 (In Controller)

$parents = StuParents::orderBy('first_name');
$parents = $parents->get();


In View

@foreach($parents as $student)

//Code

@endforeach



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xMupY4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire