public function search(Request $request) {
// Get the search value from the request
$search = $request->input('search');
// Search in the title and body columns from the posts table
$posts = Post::query()
->where('title', 'LIKE', "%{$search}%")
->orWhere('body', 'LIKE', "%{$search}%")
->take(3)
->get();
// Return the search view with the resluts compacted
return view('search-results', compact('posts'));
}
< /code>
Вот результаты поиска < /p>
if($posts->isNotEmpty())
@foreach ($posts as $post)
{{ $post->title }}
image }}">
@endforeach
@else
No posts found
@endif
< /code>
Это форма < /p>
Search
Подробнее здесь: https://stackoverflow.com/questions/795 ... h-of-posts
Мобильная версия