Completed
Push — master ( cacc5b...d7ee0c )
by Christopher
01:15
created

Task::records()   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\BelongsTo;
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 creator() : BelongsTo
33
    {
34
        return $this->belongsTo(get_class(user_model()));
35
    }
36
37
    public function status() : BelongsTo
38
    {
39
        return $this->belongsTo(Status::class);
40
    }
41
42
    public function priority() : BelongsTo
43
    {
44
        return $this->belongsTo(Priority::class);
45
    }
46
47
    public function projects() : MorphToMany
48
    {
49
        return $this->morphToMany(Project::class, 'projectable');
50
    }
51
52
    public function records() : MorphMany
53
    {
54
        return $this->morphMany(Record::class, 'recordable');
55
    }
56
}
57