TimeLog   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 3 1
A project() 0 3 1
A getNumberOfSecondsForHumansAttribute() 0 3 1
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