A developer usually must face two types of projects: Applications and applications, as follows:

For applications, I intend something that you can do, maybe in a quick way, with some workarounds and some hacks, here and there. Also, I know that you know what I am talking about. That site you made for a friend, a little blog, and so on.

Let’s be clear and serious, you can’t make every application with the same, perfect care. Being honest, neither me nor probably any one does. Then, you have to deal with Applications. Things can get really serious there, and you must be able to build a maintainable, awesome application structure.

It’s not just about something that works; in this case, I am thinking about something that can scale easily, with a good quality code base. It’s not just about calling your models from controllers. That’s not enough. You could stumble upon many issues: testability, maintainability, and also in following some principles.

In this chapter, we will explore two different ways to extend Eloquent more seriously.

In the very first part, you will learn how to extend the Eloquent Model class. Actually, the Model does many things, but what if we need something more? No problem: extending the existing Model class will be a bed of roses if standing on the shoulders of a giant.

Have you ever heard about the Ardent Project? It’s a package for Laravel 4 that extends the Model class, adding some super powers: self-validating models and auto-hydrating from the request input data.

You’ll make something similar for the Laravel 5 Eloquent Model, and I will show you how to do it step by step.

However, as mentioned earlier , Laravel is mostly about freedom, especially when it comes to freedom in organizing your projects. Now, a really interesting trend is the repository pattern. It’s a way to abstract your code in a better way and separate responsibilities. For a project bigger than the bakery&r