I've noticed that Eloquent models support a saveOrFail() method, yet I see no real evidence on the web of people discussing its use. Basically, it wraps the save operation in a transaction, which seems very sensible to me.
My question is, why is this not the default? Why should I opt for the standard save method over this one?
I would guess most of the time you would perform actions that update one row in the database, if it fails somewhere, the row won't get updated. Database transactions wouldn't do anything in these situations.
In some situations maybe you want to delete 3 users and it fails after the first 2 have been deleted. Still you wouldn't want to rollback the whole process, because they're not bound to each other, so you fix the problem and delete the 3rd user.
In situations of all or nothing, when the actions are bound to each other and if one fails, the whole process should be rolled back, this is when you need database transactions.
I guess most of the time if a single record save fails it wouldn't be written to the DB anyway? Maybe :-) Starting/committing a transaction can (as far as I remember) have different outcomes depending on the DB you're using & config (esp. when you're doing them in parallel) so you might not get quite what you expect - so being explicit when you want a transaction is, probably, better?
Edit: so I may have just duplicated some of the previous replies - this is what comes of getting distracted by your cute cat when typing a reply ;-) Damn her and her cute face... ;-)