#6 Eloquence

Eloquence is a package to extend Laravel 5’s base Eloquent models and functionality. It provides a number of utilities and classes to work with Eloquent in new and useful ways, such as camel cased attributes (for JSON apis), count caching, uuids and more.

Installation

Install the package via composer:

composer require kirkbushell/eloquence:~1.3

For Laravel 4, please install the 1.1.4 release. Please note that this is no longer supported and won’t receive any new features, only security updates.

composer require kirkbushell/eloquence:1.1.5

Usage

First, add the eloquence service provider to your config/app.php file:

'EloquenceEloquenceServiceProvider',

It’s important to note that this will automatically re-bind the Model class that Eloquent uses for many-to-many relationships. This is necessary because when the Pivot model is instantiated, we need it to utilise the parent model’s information and traits that may be needed.

You should now be good to go with your models.

 

Links