Inside Route, I am trying to pass an array inside view method and trying to display all the data in my blade template which that view is returning. While hitting that route, i am getting this error.
This is web.php file with all the routes
Route::get('/listing', function(){
return view('listings', [
'heading' => 'Latest Listing',
'listings' => [
'id' => 1,
'title' => 'Listing One',
'description' => 'Description One for Listing one... also some random text to make it look like a description.'
],
[
'id' => 2,
'title' => 'Listing Two',
'description' => 'Description Two for Listing two... also some random text to make it look like a description.'
]
]);
});
**This is listings.blade.php file **
<h1>{{$heading}}</h1>
@foreach ($listings as $listing)
<h2>{{$listing['title']}}</h2>
@endforeach