Test Failed
Push — dev6 ( e3f62b...d58043 )
by Ron
17:13
created

User   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 18
c 1
b 0
f 0
dl 0
loc 52
rs 10
ccs 6
cts 6
cp 1

5 Methods

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