Looking at the transaction code in Illuminate\Database\Connection.php it makes sense that having both records inserted into the Device table is happening.
I would wager that this is the intended behaviour and not a feature/bug. Dealing with transactions across multiple separate pieces of code is almost as terrible as dealing with time zones or character encoding. It looks like the transactions
property of the Connection
instance is an unfortunate necessity to work around people beginning multiple transactions.
As transactions are meant to allow a single 'atomic' write to multiple database tables in order to support atomic actions in your business logic, it doesn't make sense to me that you would rollback a portion of the transaction. It really should be an all or nothing thing.
Perhaps it should be documented somewhere that nested transactions are not supported by Eloquent.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community