'datetime', ]; public function teams() { return $this->hasManyThrough( 'App\Models\Core\Auth\Team', 'App\Models\Core\Auth\TeamUser', 'user_id', 'id', 'id', 'team_id' ); } public function scopeByTeam($query, $id) { return $query->whereHas('teams', function ($query) use ($id) { $query->where('id', $id); }); } public function scopeByUniqueTeam($query) { return $query->has('teams', '=', 1); } public function scopeActive($query) { return $query->where('active', 1); } public function sendPasswordResetNotification($token) { $this->notify(new ResetPasswordNotification($token)); } public function sendNewUserNotification($token) { $this->notify(new NewUserNotification($token, $this)); } public function getLastNameAttribute($value) { return mb_strtoupper($value); } public function getFirstNameAttribute($value) { return mb_convert_case($value, MB_CASE_TITLE); } public function getNameAttribute($value) { if ($value ?? false) { return $value; } return $this->first_name.' '.$this->last_name; } public function getLastLogin($format = 'YYYY-MM-DD HH:mm:ss', $default = '') { if ($this->last_login === null) { return $default; } return Carbon::createFromTimeString($this->last_login)->isoFormat($format); } public function getRolesList() { $res = []; foreach ($this->roles as $role) { $res[] = __($role->display_name); } if (! $res ?? true) { return '-'; } return implode(', ', $res); } public function getAvatarPathAttribute() { return public_path('images/avatars/'.md5($this->id.$this->email).'.jpg'); } public function getAvatarUrlAttribute() { if (is_file($this->avatar_path)) { $ts = filemtime($this->avatar_path); return asset('images/avatars/'.md5($this->id.$this->email).'.jpg?t='.$ts); } return asset('/assets/vendor/boilerplate/images/default-user.png'); } }