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

User::getInitialsAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 0
crap 2
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