Skip to content

Instantly share code, notes, and snippets.

@fokosun
Created October 10, 2017 12:01
Show Gist options
  • Save fokosun/6f01f6955824420502c8e740fe3e0989 to your computer and use it in GitHub Desktop.
Save fokosun/6f01f6955824420502c8e740fe3e0989 to your computer and use it in GitHub Desktop.
<?php
namespace App;
use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
use Authenticatable, Authorizable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'password'
];
/**
* Append links attribute.
*
* @var array
*/
protected $appends = ['_links'];
/**
* Set attributes links
*
* @return array
*/
public function getLinksAttribute()
{
return [
'self' => app()->make('url')->to("/users/{$this->attributes['id']}")
];
}
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'created_at', 'updated_at'
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment