attributes['settings'] = $settings; } public function getSettingsAttribute($settings) { if (is_string($settings)) { $decoded = json_decode($settings, true); return $decoded ?: $settings; } return $settings; } public function setProductVariationIdAttribute($variations) { if (is_array($variations)) { $value = json_encode($variations, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } elseif (is_numeric($variations)) { $value = json_encode([(int)$variations], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } else { $value = json_encode([], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } $this->attributes['product_variation_id'] = $value; } public function getProductVariationIdAttribute($value) { if (is_string($value)) { $decoded = json_decode($value, true); return $decoded ?: []; } return []; } /** * One2One: Dwonloadable Files belongs to one product * * @return \FluentCart\Framework\Database\Orm\Relations\BelongsTo */ public function product() { return $this->belongsTo(Product::class, 'post_id', 'ID'); } public function download_permissions() { return $this->hasMany(OrderDownloadPermission::class, 'download_id', 'id'); } public function getSignedDownloadUrl(): string { return DownloadService::getDownloadableUrlFromDownload($this->toArray()); } }