Ошибка: Attempt to read property "title" on string
Вот тут:
<div class="col-md-8">
<h3>List of Results</h3>
<table class="table table-striped">
<tr>
<th>title</th>
</tr>
@foreach($posts as $search)
<tr>
<td>{{ $search->title }}</td>
<td>{{ $search->name }}</td>
</tr>
@endforeach
</table>
{{ $posts->appends(request()->except('page'))->links() }}
</div>
Это контроллер:
$posts = DB::table('station as p')->select('p.*','u.name')
->join('cities as u','p.city_id','=','u.id');
if( $request->input('search')){
$posts = $posts->where('p.title', 'LIKE', "%" . $request->search . "%")
->orWhere('u.name', 'LIKE', "%" . $request->search . "%");
}
$posts = $posts->paginate(16);
return view('search', compact('data'));