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

User::FileLinks()   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
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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