63 lines
2.2 KiB
PHP
63 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Traits\Models\ActivityLog;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* @property string $title_part1 Première partie du titre h1 de l'accueil.
|
|
* @property string $title_part2 Deuxième partie du titre h1 de l'accueil.
|
|
* @property string $title_part3 Dernière partie du titre h1 de l'accueil.
|
|
* @property string $picture Path de l'image de la page d'accueil (640px * 390px).
|
|
* @property string $picture_alt Attribut alt de l'image de la page d'accueil.
|
|
* @property string $picture_title Attribut title de l'image de la page d'accueil.
|
|
* @property string $presentation_title Titre de la partie 'présentation' de la page d'accueil.
|
|
* @property string $presentation_content WYSIWYG - Contenu de la partie présentation de la page d'accueil.
|
|
* @property-read \Carbon\Carbon $created_at Created date.
|
|
* @property-read \Carbon\Carbon $updated_at Updated date.
|
|
*/
|
|
class Homepage extends Model
|
|
{
|
|
use ActivityLog;
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'title_part1',
|
|
'title_part2',
|
|
'title_part3',
|
|
'picture',
|
|
'picture_alt',
|
|
'picture_title',
|
|
'presentation_title',
|
|
'presentation_content',
|
|
];
|
|
|
|
/**
|
|
* Perform any actions required after the model boots.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function () {
|
|
throw new \RuntimeException("Creating a new page is not authorized");
|
|
});
|
|
static::updating(function (self $model) {
|
|
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
|
});
|
|
static::updated(function (self $model) {
|
|
FileStorageHelper::removeOldFile($model, 'picture');
|
|
});
|
|
static::deleting(function () {
|
|
throw new \RuntimeException('Deleting a page is not authorized');
|
|
});
|
|
}
|
|
}
|