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