F
Filament2y ago
qcol

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
kenl1666
kenl166612mo ago
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
toeknee
toeknee12mo ago
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
Want results from more Discord servers?
Add your server