{"repo":"mvanduijker/laravel-transactional-model-events","free":true,"listed":false,"github":"https://github.com/mvanduijker/laravel-transactional-model-events","clone":"git clone https://github.com/mvanduijker/laravel-transactional-model-events.git","description":"Add eloquent model events fired after a transaction is committed or rolled back","language":"PHP","stars":75,"topics":["transaction","database","eloquent","eloquent-models","laravel","php"],"license":"MIT","category":"databases-storage","readme_excerpt":"Laravel Transactional Model Events Add transactional events to your eloquent models. Will automatically detect changes in your models within a transaction and will fire events on commit or rollback. Should mimic the same functionality as transactional callbacks in Ruby on Rails. You want to use this if you want to listen on events fired by models within a transaction and you want to be sure the transaction has completed successfully (or is rolled back). Installation You can install the package via composer: Usage Just add the trait TransactionalAwareEvents to your model or base model. The following events will become available: afterCommit.created afterCommit.saved afterCommit.updated afterCommit.deleted afterCommit.restored afterCommit.forceDeleted afterRollback.created afterRollback.saved afterRollback.updated afterRollback.deleted afterRollback.restored afterRollback.forceDeleted You can add listeners in you EventServiceProvider the same way as normal events Or you can put them in your model boot method: You should also be able to map them to event classes And as icing on the cake, you can observe them with the following methods: afterCommitCreated afterCommitSaved afterCommitUpdated afterCommitDeleted afterCommitRestored afterCommitForceDeleted afterRollbackCreated afterRollbackSaved afterRollbackUpdated afterRollbackDeleted afterRollbackRestored afterRollbackForceDeleted For example: And register the observer in you ServiceProvider: Since Laravel version 10.44 it's also ","default_branch":null,"files":null,"tree":[],"storefront":"/r/mvanduijker","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mvanduijker/laravel-transactional-model-events/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}