Passed
Push — dev6 ( 6e2ff7...b01572 )
by Ron
18:29
created

User::UserRoles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 1
cts 1
cp 1
cc 1
nc 1
nop 0
crap 1
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;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Notifications\Notifiable requires the property $email which is not provided by App\Models\User.
Loading history...
15
    use SoftDeletes;
16
    use CanResetPassword;
1 ignored issue
show
Bug introduced by
The trait Illuminate\Auth\Passwords\CanResetPassword requires the property $email which is not provided by App\Models\User.
Loading history...
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