Chapter 4. Eloquent ORM

In the previous chapter, we touched on Eloquent, the object-relational mapper (ORM) that ships with Laravel. Eloquent acts as the model layer (the M in MVC) in our applications. As it is such a big part of most applications built in Laravel, we are going to take a look at Eloquent in more detail.

In this chapter, we will cover the following topics:

  • Reading and writing data to our database
  • Relationships between models
  • Query scopes
  • Model events and observers
  • Collections

Eloquent conventions

Eloquent has some conventions, which, if followed, will make your life easier. This approach is known as convention over configuration, which means, if you follow these conventions, you will have to do very little configuration for things to "just ...

Get Laravel 5 Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.