Closed aspitzer closed 6 years ago
Hi @aspitzer,
Thanks for opening this issue. Can you share how you built your wrapper? isClassSearchable
relies on class_uses_recursive
Laravel helper which handles this use case.
I tried with something like this, and it works. I'd like to see what the bug could be.
class Airport extends Model
{
use GeoSearchable;
}
trait GeoSearchable
{
use Laravel\Scout\Searchable;
}
Hello @julienbourdeau
Our trait does not implement directly "Laravel\Scout\Searchable". We use directly the child classes use Laravel\Scout\Builder; use Laravel\Scout\EngineManager; use Laravel\Scout\Jobs\MakeSearchable; use Laravel\Scout\SearchableScope;
Interesting! Could you detail your usecase and why the SearchableTrait isn't doing what you want?
Before findning class_uses_recursive
I considered, using method_exists($mode, 'toSearchableArray')
. What do you think?
Otherwise I think your PR will do the job 👍
Hello! Checking if method toSearchableArray exists will also work for us since we use it on all indexed models also. That would also be perfect!
Hi Julien, any chances we can fix this today? Otherwise, I will need to create a package from my fork.
Thanks!
Sorry Julien
We were able to update our trait and extend Scout and now check passes. So we fixed on our side.
Thanks!
Great! I was afraid bypassing this check would introduce more issues that it would fix. I'm very happy to hear you were able to extend the Searchable trait.
Hello!
We have a custom trait that uses the Laravel Scout classes but from the models, we use our trait (which is basically a wrapper).
We are getting the error while running the artisan commands "... does not use the [Laravel\Scout\Searchable] trait". (But we do in our custom wrapper.
We commented the lines of code that do the check on the BackupCommand.php and PushCommand.php and the rest works perfect.
So we were thinking that maybe you could have an extra setting like you do with the folder customization, to allow to skip the check of "isClassSearchable". Maybe like: ALGOLIA_SETTINGS_SKIP_CHECK=true.
If not we can do a fork and maintain a parallel package... We can do a PR if you like!
Thanks!