Passed
Push — master ( 62a61a...c49d39 )
by Chubarov
05:18
created

Status   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeInProcess() 0 3 1
A scopeDone() 0 3 1
1
<?php
2
3
namespace agoalofalife\postman\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Status extends Model
8
{
9
    const IN_PROCESS = 'in_process';
10
    const DONE = 'done';
11
    const COLUMN_UNIQUE_NAME = 'unique_name';
12
13
    protected $fillable = ['name', 'description', 'color_rgb', self::COLUMN_UNIQUE_NAME];
14
15
    /**
16
     * Get id status "In process"
17
     * @param $query
18
     * @return int
19
     */
20 1
    public function scopeInProcess($query) : int
21
    {
22 1
        return $query->where(self::COLUMN_UNIQUE_NAME, self::IN_PROCESS)->get()->first()->id;
23
    }
24
25
    /**
26
     * Get id status in "Done"
27
     * @param $query
28
     * @return int
29
     */
30 2
    public function scopeDone($query) : int
31
    {
32 2
        return $query->where(self::COLUMN_UNIQUE_NAME, self::DONE)->get()->first()->id;
33
    }
34
}
35