Status   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 39
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A scopeIsEnabled() 0 4 1
1
<?php namespace VojtaSvoboda\Reservations\Models;
2
3
use Model;
4
use October\Rain\Database\Traits\SoftDelete as SoftDeletingTrait;
5
use October\Rain\Database\Traits\Sortable as SortableTrait;
6
use October\Rain\Database\Traits\Validation as ValidationTrait;
7
8
/**
9
 * Status class.
10
 *
11
 * @package VojtaSvoboda\Reservations\Models
12
 */
13
class Status extends Model
14
{
15
    use SoftDeletingTrait;
16
17
    use SortableTrait;
18
19
    use ValidationTrait;
20
21
    /** @var string $table The database table used by the model */
22
    public $table = 'vojtasvoboda_reservations_statuses';
23
24
    /** @var array Rules */
25
    public $rules = [
26
        'name' => 'required|max:255',
27
        'ident' => 'required|unique:vojtasvoboda_reservations_statuses',
28
        'color' => 'max:7',
29
        'enabled' => 'boolean',
30
    ];
31
32
    /** @var array $dates */
33
    public $dates = ['created_at', 'updated_at', 'deleted_at'];
34
35
    /** @var array Relations */
36
    public $belongsTo = [
37
        'reservations' => ['VojtaSvoboda\Reservations\Models\Reservation'],
38
    ];
39
40
    /**
41
     * Is enabled scope for filering only enabled statuses.
42
     *
43
     * @param $query
44
     *
45
     * @return mixed
46
     */
47
    public function scopeIsEnabled($query)
48
    {
49
        return $query->where('enabled', true);
50
    }
51
}
52