Database Transactions
How do I create/edit a relational record with a transaction? In addition to creating / editing a record, I need to perform other records / modifications to the database and I want to make sure that these data records only execute if the master data record is correctly created / modified. Is it somehow possible to use Laravel's transaction handling?
2 Replies
Same here. I try to add the DB::beginTransaction() and DB::commit() inside the lifecycle hooks of a page, An exception "There is no active transaction" throw
it depends what you are trying to do, it sounds like you should be using a Laravel Observer to moitor the creation/editing of the model to perform actions to relationships etc