Eloquent is Laravel’s built‑in object‑relational mapper that lets developers work with database records as PHP objects. It abstracts SQL behind intuitive methods, so you can create, read, update and delete data without writing raw queries. The system automatically maps class names to table names and column attributes to object properties.
Also called: Laravel ORM
Why it matters
Using Eloquent means a website can be built faster and with fewer bugs, because the data layer is consistent and easier to understand. Clients benefit from lower maintenance costs and quicker feature additions, as developers spend less time hand‑crafting SQL and more time delivering value.
How it works
Each model class extends the base Illuminate\Database\Eloquent\Model class; Laravel reads the class name to infer the corresponding table, then builds queries through the underlying query builder. When you call methods like User::where(’email’, $email)->first(), the framework compiles the appropriate SQL, runs it via PDO, and returns a model instance populated with the result set.
The mistake people make
A common error is assuming Eloquent will automatically optimise every query, leading to N+1 query problems when related models are accessed inside loops. Without explicit eager loading (e.g. with(‘posts’)), each iteration triggers a separate query, which can dramatically slow the site and increase server load.