Priority::findByIdOrName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Chriscreates\Projects\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\HasMany;
7
8
class Priority extends Model
9
{
10
    protected $table = 'priorities';
11
12
    public $primaryKey = 'id';
13
14
    public $guarded = ['id'];
15
16
    public $timestamps = true;
17
18
    public function tasks() : HasMany
19
    {
20
        return $this->hasMany(Task::class, 'priority_id', 'id');
21
    }
22
23
    public static function findByIdOrName($value)
24
    {
25
        return static::query()
26
        ->where('id', $value)
27
        ->orWhere('name', $value)
28
        ->first();
29
    }
30
}
31