fix: images from static pages are now saved in the storage folder
This commit is contained in:
parent
4f02895ac8
commit
ee912e4163
2 changed files with 16 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -23,6 +23,9 @@ Homestead.yaml
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
.npmrc
|
.npmrc
|
||||||
|
.zshrc
|
||||||
|
.npm/
|
||||||
|
.composer/
|
||||||
|
|
||||||
# Ignore public favicon
|
# Ignore public favicon
|
||||||
/public/android-chrome-192x192.png
|
/public/android-chrome-192x192.png
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\StaticPageType;
|
use App\Enums\StaticPageType;
|
||||||
|
use App\Lib\Helpers\FileStorageHelper;
|
||||||
use App\Lib\Helpers\ToolboxHelper;
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
use App\Traits\Models\ActivityLog;
|
use App\Traits\Models\ActivityLog;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
@ -17,6 +18,9 @@ use Illuminate\Support\Str;
|
||||||
* @property string $title Title for the page.
|
* @property string $title Title for the page.
|
||||||
* @property string $slug Slug of the title for the page.
|
* @property string $slug Slug of the title for the page.
|
||||||
* @property string $content WYSIWYG text content using ckeditor.
|
* @property string $content WYSIWYG text content using ckeditor.
|
||||||
|
* @property string $picture Slide picture path.
|
||||||
|
* @property string $picture_alt Slide picture alt attribute.
|
||||||
|
* @property string $picture_title Slide picture title attribute.
|
||||||
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
||||||
* @property-read \Illuminate\Support\Carbon $updated_at Updated date.
|
* @property-read \Illuminate\Support\Carbon $updated_at Updated date.
|
||||||
*
|
*
|
||||||
|
|
@ -37,6 +41,9 @@ class StaticPage extends Model
|
||||||
'seo_description',
|
'seo_description',
|
||||||
'title',
|
'title',
|
||||||
'content',
|
'content',
|
||||||
|
'picture',
|
||||||
|
'picture_alt',
|
||||||
|
'picture_title',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -61,6 +68,9 @@ class StaticPage extends Model
|
||||||
static::updating(function (self $model) {
|
static::updating(function (self $model) {
|
||||||
self::manageFields($model);
|
self::manageFields($model);
|
||||||
});
|
});
|
||||||
|
static::updated(function (self $model) {
|
||||||
|
FileStorageHelper::removeOldFile($model, 'picture');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// * ROUTABLE
|
// * ROUTABLE
|
||||||
|
|
@ -105,7 +115,9 @@ class StaticPage extends Model
|
||||||
ToolboxHelper::assertNoInternalBoUrls('content', $model->content);
|
ToolboxHelper::assertNoInternalBoUrls('content', $model->content);
|
||||||
$model->content = clean($model->content);
|
$model->content = clean($model->content);
|
||||||
}
|
}
|
||||||
|
if ($model->picture) {
|
||||||
|
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
|
||||||
|
}
|
||||||
// * TRANSFORMATIONS
|
// * TRANSFORMATIONS
|
||||||
self::setSlug($model, $model->title);
|
self::setSlug($model, $model->title);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue