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

45 lines
1 KiB
PHP

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