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

47 lines
1.1 KiB
PHP

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