Completed
Push — master ( 053977...560004 )
by Christopher
03:12
created

Task::projects()   A

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 Chriscreates\Projects\Traits\HasPriority;
6
use Chriscreates\Projects\Traits\HasStatus;
7
use Chriscreates\Projects\Traits\IsMeasurable;
8
use Chriscreates\Projects\Traits\IsRecordable;
9
use Illuminate\Database\Eloquent\Model;
10
use Illuminate\Database\Eloquent\Relations\HasOne;
11
use Illuminate\Database\Eloquent\Relations\MorphMany;
12
use Illuminate\Database\Eloquent\Relations\MorphToMany;
13
14
class Task extends Model
15
{
16
    use IsMeasurable, IsRecordable, HasStatus, HasPriority;
17
18
    protected $table = 'tasks';
19
20
    public $primaryKey = 'id';
21
22
    public $guarded = ['id'];
23
24
    public $timestamps = true;
25
26
    protected $dates = [
27
        'started_at',
28
        'delivered_at',
29
        'expected_at',
30
    ];
31
32
    public function status() : HasOne
33
    {
34
        return $this->hasOne(Status::class, 'id', 'status_id');
35
    }
36
37
    public function priority() : HasOne
38
    {
39
        return $this->hasOne(Priority::class, 'id', 'priority_id');
40
    }
41
42
    public function projects() : MorphToMany
43
    {
44
        return $this->morphToMany(Project::class, 'projectable');
45
    }
46
47
    public function records() : MorphMany
48
    {
49
        return $this->morphMany(Record::class, 'recordable');
50
    }
51
}
52