DiscussLog   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 46
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 3 1
A loggable() 0 3 1
A casts() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Models;
6
7
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
8
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9
use Illuminate\Database\Eloquent\Relations\MorphTo;
10
use Xetaravel\Models\Presenters\DiscussLogPresenter;
11
use Xetaravel\Observers\DiscussLogObserver;
12
13
#[ObservedBy([DiscussLogObserver::class])]
14
class DiscussLog extends Model
15
{
16
    use DiscussLogPresenter;
0 ignored issues
show
introduced by
The trait Xetaravel\Models\Presenters\DiscussLogPresenter requires some properties which are not provided by Xetaravel\Models\DiscussLog: $event_type, $data
Loading history...
17
18
    /**
19
     * The attributes that are mass assignable.
20
     *
21
     * @var array
22
     */
23
    protected $fillable = [
24
        'user_id',
25
        'loggable_id',
26
        'loggable_type',
27
        'event_type',
28
        'data'
29
    ];
30
31
    /**
32
     * The attributes that should be cast.
33
     */
34
    protected function casts(): array
35
    {
36
        return [
37
            'data' => 'array'
38
        ];
39
    }
40
41
    /**
42
     * Get the user that owns the log.
43
     *
44
     * @return BelongsTo
45
     */
46
    public function user(): BelongsTo
47
    {
48
        return $this->belongsTo(User::class)->withTrashed();
49
    }
50
51
    /**
52
     * Get the loggable relation.
53
     *
54
     * @return MorphTo
55
     */
56
    public function loggable(): MorphTo
57
    {
58
        return $this->morphTo();
59
    }
60
}
61