-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
[Bug]: Using a User class that does not extend Illuminate\Foundation\Auth\User crashes when a Rappasoft\LaravelLivewireTables\Events\LaravelLivewireTablesEvent is triggered #1949
Comments
Does your custom User model utilise the "Illuminate\Contracts\Auth\Authenticatable" interface? It's probably an oversight that Illuminate\Foundation\Auth\User is being used rather than the Authenticatable Interface. Otherwise, I'll probably need to add in some customisations to swap in ability to use custom Events. What I want to avoid is a non-typed property as default. |
Thanks for answering, and answering quickly. Our model indeed implements de I'm totally on board with typing everything. In this case defining the user property as If you want, I can submit a pull request for this change. |
Ah that's not painful at all in that case! Please do feel free to issue a PR, I 100% encourage it, otherwise you'll probably have a wait for 2-3 minor releases (approx 3-4 weeks) before I can release a fix for this particular issue. Please do feel free to reach out to me on the official Discord as well if you stumble upon anything that you're not sure of, Discord is absolutely a faster way to get hold of me than GitHub. |
Released in 3.4.21 |
What happened?
When your application uses a User class that does not extend Illuminate\Foundation\Auth\User, livewire-datables crashes if you try to show/hide columns.
Not tested but can be implied from the code base: This also happens for any Rappasoft\LaravelLivewireTables\Events\LaravelLivewireTablesEvent
How to reproduce the bug
Setup:
Illuminate\Foundation\Auth\User
, in this example it'sApp\Models\Utilisateur
) , using the AuthServiceProviderResult:
the component crashes with the following error message
Expected behavior:
Triggering any kind of Event works fine regardless of the User class used by the application
Tested version:
Package Version
3.4.20
PHP Version
8.3.x
Laravel Version
10.48.12
Alpine Version
3.14
Theme
None
Notes
The issue arises from the definition of the LaravelLivewireTablesEvent's $user property.
The type of the property may not match the actual answer from auth()->user().
Removing the type of the $user attribute is enough to solve the issue.
On top of that, at the moment of writing, I cannot find any use of the LaravelLivewireTablesEvent::$user property.
I may not be fully aware of the Laravel event system, and I Imagine I either didn't look well enough, or it's been done for a future use.
As to why a Laravel application would not use a default User class that extends the default laravel class, I would say this is fairly irrelevant, as each developper is free to accomodate their own needs in the way they desire. Laravel works just fine by entirely replacing their User classes, and so should any laravel library.
Error Message
No response
The text was updated successfully, but these errors were encountered: