An eloquent-like model, for Laravel and other frameworks

Installs: 7 473

Dependents: 1

Stars: 35

Watchers: 1

Forks: 5

Open Issues: 1

v1.0.3 2015-05-14 09:10 UTC


Build Status Coverage Status

This model provides an eloquent-like base class that can be used to build custom models in Laravel or other frameworks.


class User extends Model {

    protected $hidden = ['password'];

    protected $casts ['age' => 'integer'];

    public function save()
        return API::post('/items', $this->attributes);

    public function setBirthdayAttribute($value)
        $this->attributes['birthday'] = strtotime($value);

    public function getBirthdayAttribute($value)
        return new DateTime("@$value");

    public function getAgeAttribute($value)
        return $this->birthday->diff(new DateTime('now'))->y;

$item = new User(array('name' => 'john'));
$item->password = 'bar';

echo $item; // {"name":"john"}


  • Accessors and mutators
  • Model to Array and JSON conversion
  • Hidden attributes in Array/JSON conversion
  • Appending accessors and mutators to Array/JSON conversion
  • Attribute casting

You can read more about these features and the original Eloquent model on


Install using composer:

composer require jenssegers/model

Optaional: and add an alias to the bottom of `config/app.php`:

'Model'           => 'Jenssegers\Model\Model',