Passed
Push — dev5a ( 2c238c...96dd50 )
by Ron
07:38
created

User   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFullNameAttribute() 0 3 1
A getInitialsAttribute() 0 3 1
A UserLogins() 0 3 1
A FileLinks() 0 3 1
A LastUserLogin() 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 276
    public function getFullNameAttribute()
25
    {
26 276
        return "{$this->first_name} {$this->last_name}";
27
    }
28
29 68
    public function getInitialsAttribute()
30
    {
31 68
        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