*/ protected $fillable = [ 'key', 'value', 'title', 'image_settings', 'logo', 'brand_id' ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'image_settings' => 'array', ]; /** * The "booted" method of the model. * * @return void */ protected static function boot(): void { static::creating(function (self $model) { $model->logo = FileHelper::storeFile($model, $model->logo, true); }); static::updating(function (self $model) { $model->logo = FileHelper::storeFile($model, $model->logo, true); }); static::updated(function (self $model) { FileHelper::removeOldFile($model, 'logo'); }); static::deleted(function (self $model) { FileHelper::removeFile($model, 'logo'); }); parent::boot(); } /** * Get the brand that owns the url. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Brand, $this> */ public function brand() { return $this->belongsTo(Brand::class); } /** * Get the history for the url. * * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\UrlHistory, $this> */ public function history() { return $this->hasMany(UrlHistory::class); } }