lazychaser/laravel-nestedset

Method `usesSoftDelete` conflicts with the `Searchable` trait

David-Petrov opened this issue · 2 comments

Inside the NodeTrait trait, there's a static method usesSoftDelete which has the exact same signature as the one defined in the Searchable trait from the Laravel Scout package. I supposed this is a recent issue or has been overlooked, but it could be fixed by simply renaming the method to usesSoftDeletes or something (all in all 8 occurences within the package).

Many thanks for the great work!

I just came across the exact same issue and worked around it using insteadof. It looks like both traits are using this method to determine the exact same thing in their own way, so it doesn't matter which we use.

use Searchable, NodeTrait {
    Searchable::usesSoftDelete insteadof NodeTrait;
}

Hopefully that helps someone else if there's not a change to either package.

@edjeavons I solved it the same way eventually. Surprisingly, I had never heard of that PHP feature before, since I never had the need and my habits from other languages kind of prevented me to look up something like that. So it turns out, it's not such a big issue. I remember deciding in favor of Scout's implementation, because at the end there was some difference making it better... plus it's the native one in that regard.

Thank you for that comment, I had forgotten I had written here. Case closed! :)