A Laravel eloquent-like model class, for Laravel and other frameworks
joemugen/eloquenty-model is a Laravel package for a laravel eloquent-like model class, for laravel and other frameworks.
It currently has 0 GitHub stars and 3.751 downloads on Packagist (latest version 1.1.0).
Install it with composer require joemugen/eloquenty-model.
Discover more Laravel packages by joemugen
or browse all Laravel packages to compare alternatives.
Last updated
This model provides a 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 joemugen/eloquenty-model
use JoeMugen\EloquentyModel\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(['name' => 'John']);
$item->password = 'secret';
echo $item; // {"name":"John"}