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

Incorrect error 'The model "App\Models\X" must have the required orchid/platform traits.' #89

Open
vilocity-brian opened this issue Jul 7, 2023 · 1 comment

Comments

@vilocity-brian
Copy link

Because of the way Orchid\Crud\Arbitrator checks if the model implements the required traits (Filterable), it only finds the trait if the model directly uses it... but not if the model extends a model that has use Filterable;

Three solutions come to mind:

  1. Write a new function like the trait_uses_recursive helper function that also traverse the parent classes.
  2. Stop validating the traits and rely on the developers to understand the Call to undefined method Illuminate\Database\Eloquent\Builder::filters() error they'll get.
  3. Improve the error to state that the trait must be included directly on the Model being used as a resources.

I'm mostly raising this issue so that if someone else runs into the error, they don't spin their wheels for 5 hours like I did. If nothing changes, at least this issue report may come up in their search.

In the meantime, I suggest at least a documentation update.
orchidsoftware/orchid.software@8aded35

@parse-code
Copy link

@vilocity-brian you saved my day, bro

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

No branches or pull requests

2 participants