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