TimeLog::user()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use App\Events\TimeLogSaved;
6
use Illuminate\Database\Eloquent\Model;
7
8
class TimeLog extends Model
9
{
10
    /* @var array $fillable The fields which are mass assignable */
11
    protected $fillable = ['project_id', 'user_id', 'number_of_seconds'];
12
13
    /**
14
     * The event map for the model.
15
     *
16
     * @var array
17
     */
18
    protected $dispatchesEvents = [
19
        'saved' => TimeLogSaved::class
20
    ];
21
22
    public $appends = ['number_of_seconds_for_humans'];
23
24
    /**
25
     * A time log belongs to a project
26
     *
27
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
28
     */
29
    public function project()
30
    {
31
        return $this->belongsTo(Project::class);
32
    }
33
34
    /**
35
     * A time log belongs to a user
36
     *
37
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
38
     */
39
    public function user()
40
    {
41
        return $this->belongsTo(User::class);
42
    }
43
44
    /**
45
     * Get the number of seconds for humans attribute
46
     *
47
     * @return string
48
     */
49
    public function getNumberOfSecondsForHumansAttribute()
50
    {
51
        return timeDiffForHumans($this->number_of_seconds);
52
    }
53
}
54