Merge branch 'develop' into trunk

This commit is contained in:
Noah Lancien 2025-07-10 10:35:32 +02:00
commit 2e2c64ed87

View file

@ -65,21 +65,13 @@ class Settings extends Model
protected static function booted(): void
{
static::creating(function (self $model) {
// * TRANSFORMATIONS
/** @phpstan-ignore-next-line */
if ($model->logo instanceof UploadedFile) {
$model->logo = ShowroomFileHelper::storeFileWithUUIDName($model->logo, $model);
}
self::manageFields($model);
});
static::created(function (self $model) {
self::resetCache($model->tenant_id);
});
static::updating(function (self $model) {
// * TRANSFORMATIONS
/** @phpstan-ignore-next-line */
if ($model->logo instanceof UploadedFile) {
$model->logo = ShowroomFileHelper::storeFileWithUUIDName($model->logo, $model);
}
self::manageFields($model);
});
static::updated(function (self $model) {
FileHelper::removeOldFile($model, 'logo');
@ -93,6 +85,24 @@ class Settings extends Model
// * METHODS
/**
* Common methods function.
*
* @param self $model
* @return void
*/
private static function manageFields(self $model)
{
// * TRANSFORMATIONS
/** @phpstan-ignore-next-line */
if ($model->logo instanceof UploadedFile) {
$model->logo = ShowroomFileHelper::storeFileWithUUIDName($model->logo, $model);
}
if (!$model->locales) {
$model->locales = [];
}
}
/**
* Get from cache a Setting model with a key like this : {tenant}_settings and for remember it 24 hours.
*