Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Worklog
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 creator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Models;
6
7use Carbon\Carbon;
8use Engelsystem\Models\User\User;
9use Engelsystem\Models\User\UsesUserModel;
10use Illuminate\Database\Eloquent\Factories\HasFactory;
11use Illuminate\Database\Eloquent\Relations\BelongsTo;
12use Illuminate\Database\Query\Builder as QueryBuilder;
13
14/**
15 * @property int         $id
16 * @property int         $creator_id
17 * @property float       $hours
18 * @property string      $comment
19 * @property Carbon      $worked_at
20 * @property Carbon|null $created_at
21 * @property Carbon|null $updated_at
22 *
23 * @property-read User $creator
24 *
25 * @method static QueryBuilder|Worklog[] whereId($value)
26 * @method static QueryBuilder|Worklog[] whereCreatorId($value)
27 * @method static QueryBuilder|Worklog[] whereWorkedAt($value)
28 * @method static QueryBuilder|Worklog[] whereHours($value)
29 * @method static QueryBuilder|Worklog[] whereComment($value)
30 */
31class Worklog extends BaseModel
32{
33    use HasFactory;
34    use UsesUserModel;
35
36    /** @var bool Enable timestamps */
37    public $timestamps = true; // phpcs:ignore
38
39    /** @var array<string, string> */
40    protected $casts = [ // phpcs:ignore
41        'user_id'    => 'integer',
42        'creator_id' => 'integer',
43        'hours'      => 'float',
44        'worked_at'  => 'datetime',
45    ];
46
47    /**
48     * The attributes that are mass assignable.
49     *
50     * @var array<string>
51     */
52    protected $fillable = [ // phpcs:ignore
53        'user_id',
54        'creator_id',
55        'hours',
56        'comment',
57        'worked_at',
58    ];
59
60    public function creator(): BelongsTo
61    {
62        return $this->belongsTo(User::class, 'creator_id');
63    }
64}