Created
October 10, 2017 12:01
-
-
Save fokosun/6f01f6955824420502c8e740fe3e0989 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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