Library   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getLoansCount() 0 3 1
A getAuthIdentifierName() 0 3 1
A settings() 0 3 1
A ips() 0 3 1
A loans() 0 3 1
A getActiveLoansCount() 0 3 1
A items() 0 3 1
A getOptionsAttribute() 0 6 2
A setOptionsAttribute() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Foundation\Auth\User as Authenticatable;
6
use Illuminate\Notifications\Notifiable;
7
use Illuminate\Support\MessageBag;
8
9
class Library extends Authenticatable
10
{
11
12
    use Notifiable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Notifications\Notifiable requires the property $email which is not provided by App\Library.
Loading history...
13
14
    public function ips()
15
    {
16
        return $this->hasMany(LibraryIp::class);
17
    }
18
19
    public function settings()
20
    {
21
        return $this->hasMany(ThingSettings::class);
22
    }
23
24
    public function loans()
25
    {
26
        return $this->hasMany(Loan::class);
27
    }
28
29
    public function items()
30
    {
31
        return $this->hasMany(Item::class);
32
    }
33
34
    public function getOptionsAttribute($value)
35
    {
36
        if (is_null($value)) {
37
            return json_decode('{}', true);
38
        }
39
        return json_decode($value, true);
40
    }
41
42
    public function setOptionsAttribute($value)
43
    {
44
        $this->attributes['options'] = json_encode($value);
45
    }
46
47
    /**
48
     * The database table used by the model.
49
     *
50
     * @var string
51
     */
52
    protected $table = 'libraries';
53
54
    /**
55
     * The attributes excluded from the model's JSON form.
56
     *
57
     * @var array
58
     */
59
    protected $hidden = array('password');
60
61
    /**
62
     * Get the unique identifier for the user.
63
     *
64
     * @return mixed
65
     */
66
    public function getAuthIdentifierName()
67
    {
68
        return 'email';
69
    }
70
71
    public function getLoansCount()
72
    {
73
        return $this->loans()->withTrashed()->count();
74
    }
75
76
    public function getActiveLoansCount()
77
    {
78
        return $this->loans()->count();
79
    }
80
}
81