Quick explain: Retrieving data from DB with search bar. So a couple of data retrieving due to the search. And after the search also I want to display each data in a single page by their ID. For example, lots of estates data are retrieving like: Estate_Name, Estate_Address etc in a html table.I want to put estate_name a link to go another page which just retrieve that ID's data.
I updated the problem with new codes, and getting this error now:
Trying to get property of non-object (View: /var/www/html/laravel/resources/views/show.blade.php)
This is controller:
public function show($id)
{
$estates = allestates::findOrFail($id);
return view('show')->with(['estates' => $estates]);
}
and this is my route:
Route::get('/show/{id}', 'PagesController@show');
also this the main.blade;
@foreach($estates as $estate)
<tr class="even">
<td>{{$estate->id}}</td>
<td>{{str_limit($estate->company_name, $limit = 20)}}</td>
<td><a href="/show/{{$estate->id}}">{{str_limit($estate->building_name, $limit = 20)}}</a></td>
<td>{{str_limit($estate->address, $limit = 22)}}</td>
<td>{{str_limit($estate->price, $limit = 20)}}</td>
<td class="price-hidden">{{$estate->old_price}}</td>
<td>{{str_limit($estate->extend, $limit = 20)}}</td>
<td>{{str_limit($estate->rooms, $limit = 20)}}</td>
<td>{{str_limit($estate->entry, $limit = 20)}}</td>
</tr>
@endforeach
and this is the show.blade:
@foreach($estates as $estate)
<tr class="even">
<td>{{$estate->id}}</td>
<td>{{str_limit($estate->company_name, $limit = 20)}}</td>
<td>{{str_limit($estate->building_name, $limit = 20)}}</td>
<td>{{str_limit($estate->address, $limit = 22)}}</td>
<td>{{str_limit($estate->price, $limit = 20)}}</td>
<td class="price-hidden">{{$estate->old_price}}</td>
<td>{{str_limit($estate->extend, $limit = 20)}}</td>
<td>{{str_limit($estate->rooms, $limit = 20)}}</td>
<td>{{str_limit($estate->entry, $limit = 20)}}</td>
</tr>
@endforeach
what am I doing wrong here? Any idea? Thank you! And also I have show blade that I want to just display one ID's data after click.