Passed
Push — master ( 054b32...1c77af )
by Ron
07:39 queued 12s
created

User   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 45
ccs 8
cts 10
cp 0.8
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A UserSettings() 0 3 1
A getFullNameAttribute() 0 3 1
A UserLogins() 0 3 1
A LastUserLogin() 0 3 1
A FileLinks() 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
    /**
15
     * The attributes that are mass assignable.
16
     *
17
     * @var array
18
     */
19
    protected $fillable = ['role_id', 'username', 'first_name', 'last_name', 'email', 'password', 'password_expires', 'active'];
20
    protected $hidden = ['password', 'remember_token', 'is_installer', 'active', 'created_at', 'password_expires', 'updated_at', 'user_id', 'username'];
21
    //  Database primary key
22
    protected $primaryKey = 'user_id';
23
24
    protected $appends = [ 'full_name' ];
25
    protected $casts = [
26
        'created_at' => 'datetime:M d, Y',
27
        'updated_at' => 'datetime:M d, Y',
28
        'deleted_at' => 'datetime:M d, Y'
29
    ];
30
31 304
    public function getFullNameAttribute()
32
    {
33 304
        return "{$this->first_name} {$this->last_name}";
34
    }
35
36
    public function UserLogins()
37
    {
38
        return $this->hasMany('App\UserLogins', 'user_id', 'user_id');
39
    }
40
41 2
    public function LastUserLogin()
42
    {
43 2
        return $this->hasOne('App\UserLogins', 'user_id', 'user_id')->latest();
44
    }
45
46 2
    public function FileLinks()
47
    {
48 2
        return $this->hasMany('App\FileLinks', 'user_id', 'user_id');
49
    }
50
51 4
    public function UserSettings()
52
    {
53 4
        return $this->hasOne('App\UserSettings', 'user_id', 'user_id');
54
    }
55
}
56