Reputation:
Trying to retrieve rows which has same value(関西).
First I created a blade for this (kansai.blade) And then I set the route:
Route::get('/kansai', 'PagesController@kansai');
I set the controller:
public function kansai()
{
$estates = allestates::where('region', '=', '関西')->get();
return view('pages.kansai', compact('estates'));
}
After that gave the link in main.blade:
<li><a href="/pages/{{$estates->kansai}}"></a>関西</li>
But it returns with an error:
Trying to get property of non-object (View: /var/www/html/laravel/resources/views/welcome.blade.php)
Do I missing something here? The problem is my controller I guess? Any idea? Thank you.
Upvotes: 0
Views: 304
Reputation:
I solved the problem, it's likely my mistake actually. I already retrieved the data in kansai.blade. So I just the pass the link in main.blade
which is like below.
<li><a href="{{ url('/kansai') }}">関西</a></li>
and with this problem solved.
Upvotes: 0
Reputation:
estates is an array not an object in this context. either loop trough it or specify an index.
Upvotes: 1