laravel post request search query
public function search(Request $request){
// Get the search value from the request
$search = $request['search'];
// Search in the title and body columns from the posts table
$posts = Post::query()
->where('title', 'LIKE', "%{$search}%")
->orWhere('body', 'LIKE', "%{$search}%")
->get();
// Return the search view with the resluts compacted
return view('search', compact('posts'));
}