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
|
|
|
/** |
15
|
|
|
* The attributes that are mass assignable. |
16
|
|
|
* |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
protected $fillable = ['role_id', 'username', 'first_name', 'last_name', 'email', 'password', 'password_expires', 'active']; |
20
|
|
|
protected $hidden = ['password', 'remember_token', 'is_installer', 'active', 'created_at', 'password_expires', 'updated_at', 'user_id', 'username']; |
21
|
|
|
// Database primary key |
22
|
|
|
protected $primaryKey = 'user_id'; |
23
|
|
|
|
24
|
|
|
protected $appends = [ 'full_name' ]; |
25
|
|
|
protected $casts = [ |
26
|
|
|
'created_at' => 'datetime:M d, Y', |
27
|
|
|
'updated_at' => 'datetime:M d, Y', |
28
|
|
|
'deleted_at' => 'datetime:M d, Y' |
29
|
|
|
]; |
30
|
|
|
|
31
|
304 |
|
public function getFullNameAttribute() |
32
|
|
|
{ |
33
|
304 |
|
return "{$this->first_name} {$this->last_name}"; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function UserLogins() |
37
|
|
|
{ |
38
|
|
|
return $this->hasMany('App\UserLogins', 'user_id', 'user_id'); |
39
|
|
|
} |
40
|
|
|
|
41
|
2 |
|
public function LastUserLogin() |
42
|
|
|
{ |
43
|
2 |
|
return $this->hasOne('App\UserLogins', 'user_id', 'user_id')->latest(); |
44
|
|
|
} |
45
|
|
|
|
46
|
2 |
|
public function FileLinks() |
47
|
|
|
{ |
48
|
2 |
|
return $this->hasMany('App\FileLinks', 'user_id', 'user_id'); |
49
|
|
|
} |
50
|
|
|
|
51
|
4 |
|
public function UserSettings() |
52
|
|
|
{ |
53
|
4 |
|
return $this->hasOne('App\UserSettings', 'user_id', 'user_id'); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|