|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Notifiable; |
|
6
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
|
7
|
|
|
use Illuminate\Auth\Passwords\CanResetPassword; |
|
8
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
|
9
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable; |
|
10
|
|
|
|
|
11
|
|
|
class User extends Authenticatable |
|
12
|
|
|
{ |
|
13
|
|
|
use HasFactory; |
|
14
|
|
|
use Notifiable; |
|
|
|
|
|
|
15
|
|
|
use SoftDeletes; |
|
16
|
|
|
use CanResetPassword; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
protected $primaryKey = 'user_id'; |
|
19
|
|
|
protected $guarded = ['created_at', 'updated_at']; |
|
20
|
|
|
protected $hidden = ['role_id', 'password', 'remember_token', 'deleted_at', 'created_at', 'password_expires', 'updated_at', 'user_id']; |
|
21
|
|
|
protected $appends = ['full_name', 'initials']; |
|
22
|
|
|
protected $casts = [ |
|
23
|
|
|
'created_at' => 'datetime:M d, Y', |
|
24
|
|
|
'updated_at' => 'datetime:M d, Y', |
|
25
|
|
|
'deleted_at' => 'datetime:M d, Y' |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
/* |
|
29
|
182 |
|
* Users First and Last name combined |
|
30
|
|
|
*/ |
|
31
|
182 |
|
public function getFullNameAttribute() |
|
32
|
|
|
{ |
|
33
|
|
|
return "{$this->first_name} {$this->last_name}"; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/* |
|
37
|
24 |
|
* User Initials |
|
38
|
|
|
*/ |
|
39
|
24 |
|
public function getInitialsAttribute() |
|
40
|
|
|
{ |
|
41
|
|
|
return "{$this->first_name[0]}{$this->last_name[0]}"; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/* |
|
45
|
1 |
|
* Each user is assigned to a role that determines what permissions they are allowed |
|
46
|
|
|
*/ |
|
47
|
1 |
|
// public function UserRoles() |
|
48
|
|
|
// { |
|
49
|
|
|
// return $this->hasOne('App\Models\UserRoles', 'role_id', 'role_id'); |
|
50
|
|
|
// } |
|
51
|
|
|
|
|
52
|
|
|
/* |
|
53
|
|
|
* Each user has their own individual settings |
|
54
|
|
|
*/ |
|
55
|
|
|
// public function UserSetting() |
|
56
|
|
|
// { |
|
57
|
|
|
// return $this->hasMany(UserSetting::class, 'user_id', 'user_id'); |
|
58
|
|
|
// } |
|
59
|
|
|
|
|
60
|
|
|
// public function TechTipBookmark() |
|
61
|
|
|
// { |
|
62
|
|
|
// return $this->hasOne(TechTipBookmark::class, 'user_id', 'user_id'); |
|
63
|
|
|
// } |
|
64
|
|
|
} |
|
65
|
|
|
|