ldc-dam/app/Models/Historique.php

72 lines
1.3 KiB
PHP
Raw Normal View History

2019-07-22 14:54:42 +02:00
<?php
namespace App\Models;
2019-07-22 14:54:42 +02:00
2022-07-25 11:37:01 +02:00
use App\Enums\EventHistoryType;
2019-07-22 14:54:42 +02:00
use Illuminate\Database\Eloquent\Model;
class Historique extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
2019-07-22 14:54:42 +02:00
public $timestamps = false;
2022-07-25 11:37:01 +02:00
/**
* The attributes that should be cast.
*
* @var array
*/
public $casts = [
'type' => EventHistoryType::class
];
// * RELATIONSHIPS
2022-04-19 16:07:27 +02:00
/**
* BelongsTo user relation
*
2022-04-19 16:07:27 +02:00
* Get the user that owns the historique.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
2022-04-19 16:07:27 +02:00
*/
public function user()
{
return $this->belongsTo(User::class);
2022-04-19 16:07:27 +02:00
}
2019-07-22 14:54:42 +02:00
2022-04-19 16:07:27 +02:00
/**
* BelongsTo media relation
*
2022-04-19 16:07:27 +02:00
* Get the media that owns the historique.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
2022-04-19 16:07:27 +02:00
*/
public function media()
{
return $this->belongsTo(Media::class);
2022-04-19 16:07:27 +02:00
}
// * 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()
]
]
);
}
2019-07-22 14:54:42 +02:00
}