Using the Repository Pattern with Eloquent for Code That Lasts
summary
Shows how to put a repository layer on top of Eloquent to isolate persistence and keep the Laravel app simple, so the storage driver can be swapped without changing many files. Recommends moving read/write queries into repositories, exposing only contract methods via repository interfaces, using value objects to ensure valid entities, and throwing exceptions on failures to ease migrations (e.g., legacy→microservice) and simplify testing.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:17Active Record limits
- 3:47Eloquent issues
- 6:56Repository Pattern
- 8:17Refactoring with Repository
- 10:43Complex queries
- 12:32Flexible repository interfaces
- 13:58Value Objects
- 17:36Repository benefits
- 19:23Migration example
- 20:07Testing with Repository
related talks
31mModern PHP development with Laravel 5.6
32mDesign Patterns and Packages for Excellent Laravel Backoffices
40mEngineering Complex Applications with Laravel 4
21mSoftware Design Patterns in Laravel 4
27mModelling business requirements with Eloquent
37mOrganizing Code in Laravel
38mLaravel Design Patterns
32mFull stack architecture
