Passed
Push — dev5a ( c2cba2...4ce5a4 )
by Ron
07:44
created

User   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 1
b 0
f 0
dl 0
loc 43
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getFullNameAttribute() 0 3 1
A getInitialsAttribute() 0 3 1
A LastUserLogin() 0 3 1
A UserSettings() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use Illuminate\Foundation\Auth\User as Authenticatable;
8
9
class User extends Authenticatable
10
{
11
    use Notifiable;
12
    use SoftDeletes;
13
14
    protected $primaryKey = 'user_id';
15
    protected $fillable   = ['role_id', 'username', 'first_name', 'last_name', 'email', 'password', 'password_expires'];
16
    protected $appends    = ['full_name', 'initials'];
17
    protected $hidden     = ['role_id', 'password', 'remember_token', 'deleted_at', 'created_at', 'password_expires', 'updated_at', 'user_id', 'username'];
18
    protected $casts      = [
19
        'created_at' => 'datetime:M d, Y',
20
        'updated_at' => 'datetime:M d, Y',
21
        'deleted_at' => 'datetime:M d, Y'
22
    ];
23
24 316
    public function getFullNameAttribute()
25
    {
26 316
        return "{$this->first_name} {$this->last_name}";
27
    }
28
29 76
    public function getInitialsAttribute()
30
    {
31 76
        return "{$this->first_name[0]}{$this->last_name[0]}";
32
    }
33
34
    // public function UserLogins()
35
    // {
36
    //     return $this->hasMany('App\UserLogins', 'user_id', 'user_id');
37
    // }
38
39 4
    public function LastUserLogin()
40
    {
41 4
        return $this->hasOne('App\UserLogins', 'user_id', 'user_id')->latest();
42
    }
43
44
    // public function FileLinks()
45
    // {
46
    //     return $this->hasMany('App\FileLinks', 'user_id', 'user_id');
47
    // }
48
49 8
    public function UserSettings()
50
    {
51 8
        return $this->hasOne('App\UserSettings', 'user_id', 'user_id');
52
    }
53
}
54