Are you sure you have data in $posting ?
Jun 21, 2018
11
Level 1
Laravel Undefined variable:
Hi guys, just got a nooby problem, i cant fetch data from db, but the strange thing is in other folder i used
Controller:
$hosting = hosting::all() -> toArray();
return view("index",compact("hosting"));
View:
@foreach($hosting as $host) {{$host['pavadinimas']}} @endforeach
And that worked, right now i want to make a list and i using
Controller:
$posting = posting::all() -> toArray();
return view("lists.list",compact("posting"));
View:
@foreach($posting as $post)
<p>{{$post['vardas']}}</p>
@endforeach
and it;s giving me error " Undefined variable: posting (View: C:\xampp\htdocs\praktika1\resources\views\lists\list.blade.php)"
and i don't understand what i have done wrong?
Please or to participate in this conversation.