GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — master ( 273301...d40dfb )
by Nikhil
19:35 queued 09:51
created

Rack::guitars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent;
6
7
/**
8
 * App\Rack.
9
 *
10
 * @property int $id
11
 * @property int $warehouse_id
12
 * @property string $name
13
 * @property int $make_id
14
 * @property int $capacity
15
 * @property \Carbon\Carbon $deleted_at
16
 * @property-read \App\Warehouse $warehouse
17
 * @property-read mixed $used
18
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Guitar[] $guitars
19
 * @property-read mixed $usage
20
 * @property-read \App\Make $make
21
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Notification[] $notifications
22
 * @method static \Illuminate\Database\Query\Builder|\App\Rack whereId($value)
23
 * @method static \Illuminate\Database\Query\Builder|\App\Rack whereWarehouseId($value)
24
 * @method static \Illuminate\Database\Query\Builder|\App\Rack whereName($value)
25
 * @method static \Illuminate\Database\Query\Builder|\App\Rack whereMakeId($value)
26
 * @method static \Illuminate\Database\Query\Builder|\App\Rack whereCapacity($value)
27
 * @method static \Illuminate\Database\Query\Builder|\App\Rack whereDeletedAt($value)
28
 * @mixin \Eloquent
29
 */
30
class Rack extends Eloquent\Model
31
{
32
    use Eloquent\SoftDeletes;
33
34
    /**
35
     * We do not want any timestamps.
36
     *
37
     * @var bool
38
     */
39
    public $timestamps = false;
40
    /**
41
     * @var array
42
     */
43
    protected $dates = ['deleted_at'];
44
    /**
45
     * The attributes that are not mass assignable.
46
     *
47
     * @var array
48
     */
49
    protected $fillable = ['name', 'capacity', 'make_id', 'warehouse_id'];
50
51 10
    public static function boot()
52
    {
53 10
        parent::boot();
54
55 10
        static::deleting(function (Rack $rack) {
56 2
            $rack->guitars()->delete();
57 10
        });
58 10
    }
59
60
    /**
61
     * Warehouse the rack is in.
62
     *
63
     * @return Eloquent\Relations\BelongsTo
64
     */
65
    public function warehouse()
66
    {
67
        return $this->belongsTo(Warehouse::class);
68
    }
69
70
    /**
71
     * Number of used rack space.
72
     *
73
     * @return int
74
     */
75
    public function getUsedAttribute()
76
    {
77
        return $this->guitars()->unsold()->count();
78
    }
79
80
    /**
81
     * Guitars in the rack.
82
     *
83
     * @return Eloquent\Relations\HasMany
84
     */
85 2
    public function guitars()
86
    {
87 2
        return $this->hasMany(Guitar::class);
88
    }
89
90
    /**
91
     * Usage of the rack.
92
     *
93
     * @return float
94
     */
95
    public function getUsageAttribute()
96
    {
97
        return ($this->used / $this->capacity) * 100;
98
    }
99
100
    /**
101
     * Is the rack full?
102
     *
103
     * @return bool
104
     */
105
    public function isFull()
106
    {
107
        return $this->used >= $this->capacity;
108
    }
109
110
    /**
111
     * Guitar make this rack can hold.
112
     *
113
     * @return Eloquent\Relations\BelongsTo
114
     */
115
    public function make()
116
    {
117
        return $this->belongsTo(Make::class);
118
    }
119
}
120