diff --git a/.gitignore b/.gitignore index e00c845..ac19178 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ Homestead.yaml npm-debug.log yarn-error.log .npmrc +.zshrc +.npm/ +.composer/ # Ignore public favicon /public/android-chrome-192x192.png diff --git a/app/Models/StaticPage.php b/app/Models/StaticPage.php index 6773a27..024c0e0 100644 --- a/app/Models/StaticPage.php +++ b/app/Models/StaticPage.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Enums\StaticPageType; +use App\Lib\Helpers\FileStorageHelper; use App\Lib\Helpers\ToolboxHelper; use App\Traits\Models\ActivityLog; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -17,6 +18,9 @@ use Illuminate\Support\Str; * @property string $title Title for the page. * @property string $slug Slug of the title for the page. * @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 $updated_at Updated date. * @@ -37,6 +41,9 @@ class StaticPage extends Model 'seo_description', 'title', 'content', + 'picture', + 'picture_alt', + 'picture_title', ]; /** @@ -61,6 +68,9 @@ class StaticPage extends Model static::updating(function (self $model) { self::manageFields($model); }); + static::updated(function (self $model) { + FileStorageHelper::removeOldFile($model, 'picture'); + }); } // * ROUTABLE @@ -105,7 +115,9 @@ class StaticPage extends Model ToolboxHelper::assertNoInternalBoUrls('content', $model->content); $model->content = clean($model->content); } - + if ($model->picture) { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); + } // * TRANSFORMATIONS self::setSlug($model, $model->title); }