Passed
Push — dev6 ( c88035...50a53d )
by Ron
17:16
created

User   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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