Repository navigation
Replies: 2 comments 12 replies
|
What's your use case for a theoretical Typically |
12 replies
|
Since there is no much interest in the new event and there is a workaround (thanks to @henzeb) , I better close the discussion. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The idea is to add a
makingevent to the Eloquent model which is going to be bound to theModel::make()method (as thecreatingevent is bound to theModel::create()method). Why the framework needs it?Use case
Let's assume, there is a Post model and we want to automatically generate a slug from a title (when a slug is not provided). I tried to implement this functionality through Mutators (but it doesn't work because you need to call a
slugexplicitly to mutate it) and through the constructor (but I didn't find a way to access the models' attributes in there - it seems there is no way to do it).The only working way, which I've found, is to use the Model events with closures to adjust the slug.
This works for the
create()method,but this does not work for the
make()method., it's not possible to have the symmetrical behavior for
Post::make()andPost::create()because no events are bound tomake.Btw, my use case is not unique. There are other cases related to the dynamic attributes generation, for example:
I would like to propose to add the
makingevent and bound it to theModel::make()method. It seems logical for this event to exist.All reactions