ldc-domaine-de-lanvaux/app/Models/HomepageNewscast.php
2026-10-27 15:12:56 +01:00

55 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use App\Lib\ToolboxHelper;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HomepageNewscast extends Model
{
use HasFactory;
/**
* The attributes that are fillable.
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'picture',
'alt_text_picture',
'text',
'link',
'link_label',
'link_new_tab',
];
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function boot()
{
static::creating(function (HomepageNewscast $homepagenewscast): void {
if ($homepagenewscast->picture) {
$homepagenewscast->picture = ToolboxHelper::storeImage(
$homepagenewscast->picture,
$homepagenewscast->getTable()
);
}
});
static::updating(function (HomepageNewscast $homepagenewscast): void {
if ($homepagenewscast->picture) {
$homepagenewscast->picture = ToolboxHelper::storeImage(
$homepagenewscast->picture,
$homepagenewscast->getTable()
);
}
});
parent::boot();
}
}