For whatever reason, you may need to disable Laravel Nova automatically using Scout when searching. Here's how.
By default, if Nova detects you're using Laravel Scout on a model (with the Searchable
trait), it'll use this internally to perform searches.
There are a couple of reasons you might not want this to happen:
It's a pretty quick fix! Just add the usesScout
method to the Nova resource you want to control Scout for, and return false
.
class Course extends Resource
{
public static $search = [
'id', 'title', 'slug'
];
public static function usesScout()
{
return false;
}
//...
}
And that's it! Laravel Scout will now be disabled for that resource, and the search results will be performed directly from your database.