PHP code example of supportpal / eloquent-model
1. Go to this page and download the library: Download supportpal/eloquent-model library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
supportpal / eloquent-model example snippets
use Jenssegers\Model\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"}