-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[8.x] Adds dynamic properties to AnonymousNotifiable
#38628
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
[8.x] Adds dynamic properties to AnonymousNotifiable
#38628
Conversation
|
One consideration. Notification::route('mail', '[email protected]')
->name('Ludwig van Beethoven')
->instrument('Piano')
->notify(new GuitarShipped('JP45'));This behavior may or may not be desired. If it isn't then the |
|
I consider that an improvement. |
|
Well, that's a valid point. I'll disable the
When you use a notifiable Model you are still end up using message-passing magic. Using |
This reverts commit 9f9b737.
* Adds Fluent and `with()` to the AnonymousNotifiable. * Style changes * Disables dynamic calls to AnonymousNotifiable. * Update AnonymousNotifiable.php Co-authored-by: Taylor Otwell <[email protected]>
* Revert "Apply fixes from StyleCI" This reverts commit cdb14c7. * Revert "[8.x] Adds dynamic properties to `AnonymousNotifiable` (laravel#38628)" This reverts commit 9f9b737.
What?
Allows using dynamic properties like Eloquent Models to the
AnonymousNotifiable(on demand notifications).This solves the problem when a notification expects data from the notifiable, as the
AnonymousNotifiabledoesn't support gracefully chaining properties, as it difficult to manually set each of them. Worse case scenario: making another notification.This way is totally safe to get injected data from the notifiable.
The
with()method supportsArrayableobjects, so you can use a whole Model if you feel lazy.How?
I just slapped the
Fluenthelper into theAnonymousNotifiableand added thewith()method to merge multiple attributes in one go.BC?
Please...
Notes
Fluentin my opinion.with()into the Facade, so it still forces the developer to route first and merge properties later.