Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usesSoftDelete trait being applied despite being set as false in config #338

Closed
06chaynes opened this issue Dec 19, 2018 · 6 comments
Closed

Comments

@06chaynes
Copy link

06chaynes commented Dec 19, 2018

I am getting an error on a model regarding the trait method 'usesSoftDelete' failing to apply. I have 'soft_delete' set as false in the scout.php config file, so I wasn't expecting for the trait to be applied at all. Is this behaviour to be expected?

scout v6.1.3

@nunomaduro
Copy link
Member

Hey @06chaynes.

Can you detail your problem with a real use case? What is the behavior that is not working as expected?

@06chaynes
Copy link
Author

When I apply scout's Searchable trait to my model that does not implement soft deletes, it attempts to apply the usesSoftDeletes trait anyways. This is causing a conflict with another trait the model is inheriting. I thought that setting 'soft_delete' to false in the scout config would stop it from applying the usesSoftDelete trait on the model.

@nunomaduro
Copy link
Member

No problem. I am here to help you. Two questions:

  1. What do you mean by ...applying the usesSoftDelete trait on the model.? You are getting soft deleted models on your index?
  2. What do you mean by This is causing a conflict with another trait the model is inheriting?

@06chaynes
Copy link
Author

After applying the Searchable trait to my model (App\Models\Organization), I get the following error when running artisan commands like 'scout:import' or 'config:cache': Trait method usesSoftDelete has not been applied, because there are collisions with other trait methods on App\Models\Organization. The trait that it is colliding with is a nested-set package I use for this model.

@nunomaduro
Copy link
Member

Thanks for the detail.

Your model is using a trait that also contains usesSoftDelete a method. If two Traits insert a method with the same name, a fatal error is produced, if the conflict is not explicitly resolved. This is a PHP thing.

Setting scout_delete to false is irrelevant here.

Hopes this helps, I will close this issue because there no bug on Laravel Scout. Please consider to ask some help in our support channels:

@06chaynes
Copy link
Author

Ah, I was looking at it wrong I see. I decided to fork the other package in question and rename the conflicting method, all good now. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants