Enums arent using BaseEnum trait and cannot since tool low php level, need to manually implement behaviors
71 lines
1.3 KiB
PHP
71 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\EventHistoryType;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Historique extends Model
|
|
{
|
|
/**
|
|
* Indicates if the model should be timestamped.
|
|
*
|
|
* @var boolean
|
|
*/
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array
|
|
*/
|
|
public $casts = [
|
|
'type' => EventHistoryType::class
|
|
];
|
|
|
|
// * RELATIONSHIPS
|
|
|
|
/**
|
|
* BelongsTo user relation
|
|
*
|
|
* Get the user that owns the historique.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* BelongsTo media relation
|
|
*
|
|
* Get the media that owns the historique.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function media()
|
|
{
|
|
return $this->belongsTo(Media::class);
|
|
}
|
|
|
|
// * METHODS
|
|
|
|
/**
|
|
* Get the instance as an array.
|
|
*
|
|
* @return array<TKey,TValue>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return \array_merge(
|
|
parent::toArray(),
|
|
[
|
|
'type' => [
|
|
'value' => $this->type,
|
|
'label' => $this->type->label()
|
|
]
|
|
]
|
|
);
|
|
}
|
|
}
|