Currently my index method works and looks like this:
return view('books.index', [
'books' => Book::with(['author', 'publisher'])->paginate(15)
]);
But I would like to use filter() to filter results upon request, this is my best shot so far:
return view('books.index', [
'books' => Book::latest()
->filter(request(['search']))
->with(['author', 'publisher'])
->paginate(15)
->withQueryString()
]);
But I keep getting the error:
Call to undefined method Illuminate\Database\Eloquent\Builder::filter()
Any help is greatly appreciated!