[5.8] Replicating model event#28077
Conversation
|
How many different models do you have this use case for? Is it mainly a single model? |
|
@jerguslejko Why not have a replicating and a replicated event? |
|
Maybe do the replication in a method on your model and fire a custom event. IMO it doesn't seem like a common enough use-case for core. |
This is kinda what I was getting at with my comment. If you're just doing this on a particular model it may be easier to just make it a method in your application. |
|
@AbdelElrafa replicating a model does not create a new database record. therefore @taylorotwell I need to be able to dynamically register replication logic in a service provider. using the |
|
@jerguslejko I was thinking, like during the Take a look at this, https://laravel.com/docs/5.0/eloquent#model-events. |
This PR introduces "replicating" model event which is fired when
$model->replicate()is called.This is useful when "replication" is a part of the domain logic. My usecase: I need to reset an attribute every time a model is replicated, because that attribute is specific to the model.