stream-laravel icon indicating copy to clipboard operation
stream-laravel copied to clipboard

On update observer

Open imam opened this issue 5 years ago • 2 comments

Hello!

So, I want to contribute to this library. From what I understand, this library is not yet auto-update on laravel eloquent model.

So before I want to ask:

  • Do you have any reason to not include it?
  • What should I looked at before I add this feature? Backward compability? Should I add a custom option to laravel model so for anyone that use this library before would not see any difference and we'll just auto update if they choose to opt-in?

Thank you :)

imam avatar Apr 07 '20 15:04 imam

we always welcome contributions to our libraries! I am not sure what your contribution would be about, can you elaborate a bit more on it?

tbarbugli avatar Apr 08 '20 07:04 tbarbugli

Sorry for the confusion, it seems I'm not clear about what I'm talking. Let me elaborate.

So currently it seems that this library does not react on auto-update in Eloquent. What I mean is:

  • When any of my model "update", the activity on getStream does not get updated. This behaviour is not in my expectation, as what I've thought before that if we do create a new model, we can get the activityNotify method to be fired, as with a model deletion, an activity would be created or deleted on the Stream side.

This feature is important in these cases:

  • I want an update-able data relation
  • A data relation like one to many and many to many, would be impossible to do. So, in my case I have an invoice feature, that have a relation to several products, that if the Invoice is being paid, I want to notice to all of the product owner that they have product order. In Laravel, the step that we would make is: create the invoice, save the invoice, then save the association between invoices and products. The problem comes because the invoice should be saved first, but before it being saved it has no idea that there would be a relation between the invoice and products included in the invoice, so it can only notify the invoice owner, not the product owner.

Should I note that this would be a breaking change to the current Eloquent model behaviour with getStream (ActivityTrait) :)

imam avatar Apr 08 '20 11:04 imam