|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Notifiable; |
|
6
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
|
7
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable; |
|
8
|
|
|
|
|
9
|
|
|
class User extends Authenticatable |
|
10
|
|
|
{ |
|
11
|
|
|
use Notifiable; |
|
12
|
|
|
use SoftDeletes; |
|
13
|
|
|
|
|
14
|
|
|
protected $primaryKey = 'user_id'; |
|
15
|
|
|
protected $fillable = ['role_id', 'username', 'first_name', 'last_name', 'email', 'password', 'password_expires']; |
|
16
|
|
|
protected $appends = ['full_name', 'initials']; |
|
17
|
|
|
protected $hidden = ['role_id', 'password', 'remember_token', 'deleted_at', 'created_at', 'password_expires', 'updated_at', 'user_id', 'username']; |
|
18
|
|
|
protected $casts = [ |
|
19
|
|
|
'created_at' => 'datetime:M d, Y', |
|
20
|
|
|
'updated_at' => 'datetime:M d, Y', |
|
21
|
|
|
'deleted_at' => 'datetime:M d, Y' |
|
22
|
|
|
]; |
|
23
|
|
|
|
|
24
|
92 |
|
public function getFullNameAttribute() |
|
25
|
|
|
{ |
|
26
|
92 |
|
return "{$this->first_name} {$this->last_name}"; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
36 |
|
public function getInitialsAttribute() |
|
30
|
|
|
{ |
|
31
|
36 |
|
return "{$this->first_name[0]} {$this->last_name[0]}"; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function UserLogins() |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->hasMany('App\UserLogins', 'user_id', 'user_id'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
4 |
|
public function LastUserLogin() |
|
40
|
|
|
{ |
|
41
|
4 |
|
return $this->hasOne('App\UserLogins', 'user_id', 'user_id')->latest(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function FileLinks() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->hasMany('App\FileLinks', 'user_id', 'user_id'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function UserSettings() |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->hasOne('App\UserSettings', 'user_id', 'user_id'); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|