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

Status::scopeInProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 1
crap 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