Introduction to Eloquent ORM
Eloquent is Laravel's built-in object-relational mapper (ORM), and it's one of the framework's signature features. Rather than writing raw SQL for every database interaction, Eloquent lets developers work with plain PHP objects that represent rows of data.
What an ORM Actually Does
An ORM bridges the gap between a relational database and an object-oriented codebase. Each database table is represented by a model class, and each row in that table becomes an instance of that class, with columns accessible as simple object properties.
Why Eloquent Feels Different
Compared to many other ORMs, Eloquent favors simplicity and readability. Common operations read almost like plain English, and the "active record" pattern it follows means a model instance can save, update, or delete itself directly, without needing a separate repository layer.
| Concept | What It Represents |
|---|---|
| Model | A PHP class representing one database table |
| Instance | A single row within that table |
| Attribute | A column value on a given row |
| Query Builder | The underlying engine Eloquent uses to construct SQL |
Benefits of Using Eloquent
- Removes the need to hand-write most everyday SQL statements
- Automatically protects against SQL injection through parameter binding
- Supports relationships between tables with minimal extra code
- Integrates directly with Laravel's validation, pagination, and API resources
Before Eloquent can do any of this, though, it needs an actual model class to work with — which is exactly what comes next: defining models and their matching migrations.
Ready to master Laravel Training Course?
Join Uncodemy's hands-on Laravel program and build real, production-ready applications.
