| Package Data | |
|---|---|
| Maintainer Username: | jenssegers |
| Package Create Date: | 2013-03-30 |
| Package Last Update: | 2025-03-16 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-02 15:00:06 |
| Package Statistics | |
|---|---|
| Total Downloads: | 3,968,968 |
| Monthly Downloads: | 65,870 |
| Daily Downloads: | 496 |
| Total Stars: | 395 |
| Total Watchers: | 8 |
| Total Forks: | 55 |
| Total Open Issues: | 18 |
This model provides an Laravel eloquent-like base class that can be used to build custom models in Laravel or other frameworks.
You can read more about these features and the original Eloquent model on http://laravel.com/docs/eloquent
Install using composer:
composer require jenssegers/model
class User extends Model {
protected $hidden = ['password'];
protected $guarded = ['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"}