7 months ago

Foreach give error when i'm trying to display it

Posted 7 months ago by Vishaal


I'm trying to foreach some property, when i'm trying in blade it give me error message:


$vaardigheid = DB::table('instellingens')->where([
                        ['level', '=', 'Vaardigheid'],

        $vaardigheid = $vaardigheid->first();

return view('vaardigheid', compact('vaardigheid'));


 @foreach($vaardigheid as $vaardigheid)

when i return the value on controller it give me output:


error on blade:

ErrorException (E_ERROR) Trying to get property 'naam' of non-object (View: C:\xampp\htdocs\test\resources\views\aanvrager\vaardigheid.blade.php) Previous exceptions Trying to get property 'naam' of non-object (0)

why i'm getting this error message? i have use the foreach on other controller there is the same and there its working fine.

Please sign in or create an account to participate in this conversation.