I am trying to run the command php artisan scout:import "App\User"
to import user records into search driver as per documentation (Laravel 5.3 Scout Documentation). I keep getting [BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::makeAllSearchable() as an error. Why am I getting this error? I have included the searchable trait in my users controller and added the scout class to my app/config providers array, so I am struggling to see why the method doesn't exist...
You should not add the trait to the controller but to the model. So in your case to App\User.php
<?php
namespace App;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Searchable;
}
Like Jakub has said, you have to add the Searchable trait to your User model, not to the controller.
If you're using toSearchableArray()
on your model, do not forget to include the id
column in the array, otherwise it won't work.
You could also comment the toSearchableArray()
function, import the existing users and then add it back.