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

User::TechTipBookmark()   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\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