laravel post request search query

Solutions on MaxInterview for laravel post request search query by the best coders in the world

showing results for - "laravel post request search query"
Alan
12 Jun 2018
1public function search(Request $request){
2    // Get the search value from the request
3    $search = $request['search'];
4
5    // Search in the title and body columns from the posts table
6    $posts = Post::query()
7        ->where('title', 'LIKE', "%{$search}%")
8        ->orWhere('body', 'LIKE', "%{$search}%")
9        ->get();
10
11    // Return the search view with the resluts compacted
12    return view('search', compact('posts'));
13}
similar questions
queries leading to this page
laravel post request search query