XetaIO /
Xetaravel
| 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
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 |