Eloquent là lớp trừu tượng database của Laravel cung cấp giao diện hướng đối tượng để thao tác database. Thay vì SQL thuần SELECT * FROM users WHERE id=1, dùng User::find(1).
Lợi ích: không phụ thuộc vào database cụ thể (dễ chuyển đổi), tự động phòng chống SQL injection, code dễ đọc và bảo trì, relationships được tích hợp sẵn, tính năng tối ưu hóa query. Mỗi bảng có class Model tương ứng với các property khớp cột. Các method như where(), orWhere(), orderBy() có thể chain: User::where("age", ">", 18)->orderBy("name")->get(). Giảm code, tăng bảo mật, dễ test.
Eloquent is Laravel's database abstraction providing object-oriented interface to databases. Instead of raw SQL SELECT * FROM users WHERE id=1, use User::find(1).
Benefits: database-agnostic (switch databases easily), prevents SQL injection automatically, readable and maintainable code, relationships built-in, query optimization features. Each table has corresponding Model class with properties matching columns. Methods like where(), orWhere(), orderBy() chain queries fluently: User::where("age", ">", 18)->orderBy("name")->get(). Reduces code, improves security, enables testing.