Status::projects()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
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 Status extends Model
9
{
10
    protected $table = 'statuses';
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, 'status_id', 'id');
21
    }
22
23
    public function projects() : HasMany
24
    {
25
        return $this->hasMany(Project::class, 'status_id', 'id');
26
    }
27
28
    public static function findByIdOrName($value)
29
    {
30
        return static::query()
31
        ->where('id', $value)
32
        ->orWhere('name', $value)
33
        ->first();
34
    }
35
}
36