Two checkouts racing for the last item in stock is a classic bug. Build a reservation system with lockForUpdate() that closes the race for good.
#Database
Articles
Build nested, threaded comments in Laravel using a self-referencing parent_id column and a recursive Eloquent relationship.
A step-by-step guide to building a reusable tagging system that works across multiple Eloquent models using morphToMany.
Tag articles, products, and anything else through a single reusable table using a polymorphic many-to-many relationship.
Wrapping related writes in a transaction is easy to get subtly wrong. Laravel's DB::transaction() closure handles commit, rollback, and deadlock retries for you.
Laravel Notifications send the same message across mail, database, Slack, and SMS from one class. This tutorial builds a multi-channel notification system step by step.
These five underused Eloquent features will help you write less code, run fewer queries, and make your models a lot more pleasant to work with.