*/ protected $dates = ['deleted_at']; protected $guard = []; protected $guard_name = '*'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'api_token', 'account', 'status', 'class', 'leader', 'exp_op', 'unit', 'device', 'deleted_at', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', 'api_token' ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; // append attribute protected $appends = ['role_name','station']; public function userLog() { return $this->hasMany(UserLog::class); } // get role name attribute public function getRoleNameAttribute() { return $this->roles->pluck('display_name')->first(); } // get station attribute public function getStationAttribute() { return '交通警察大隊'; } // get status attribute // public function getStatusAttribute($value) // { // return $value == 0 ? '啟用' : '停用'; // } }