Merge branch 'develop' into trunk
This commit is contained in:
commit
2e2c64ed87
1 changed files with 20 additions and 10 deletions
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue