ldc-domaine-de-lanvaux/app/Models/WhoareweIcon.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 WhoareweIcon extends Model
{
use HasFactory;
/**
* Fillable fields.
*
* @var array
*/
#[\Override]
protected $fillable = [
'text',
'picture',
'alt_text_picture',
];
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function boot()
{
static::creating(function (WhoareweIcon $whoareweicon): void {
if ($whoareweicon->picture) {
$whoareweicon->picture = ToolboxHelper::storeImage($whoareweicon->picture, $whoareweicon->getTable());
}
});
static::updating(function (WhoareweIcon $whoareweicon): void {
if ($whoareweicon->picture) {
$whoareweicon->picture = ToolboxHelper::storeImage($whoareweicon->picture, $whoareweicon->getTable());
}
});
parent::boot();
}
}