'array', 'specs' => 'array', 'price' => 'decimal:2', 'original_price' => 'decimal:2', 'stock' => 'integer', 'sold' => 'integer', 'last_sync_at' => 'datetime', ]; /** * 关联店铺授权 * * @return BelongsTo */ public function shopAuth(): BelongsTo { return $this->belongsTo(ShopAuth::class); } /** * 关联SKU绑定 */ public function skuBindings(): HasMany { return $this->hasMany(PlatformSkuBinding::class, 'platform_sku_id'); } /** * 获取当前生效的绑定 */ public function activeBinding(): HasOne { return $this->hasOne(PlatformSkuBinding::class, 'platform_sku_id')->where('is_active', true); } /** * 获取状态标签 * * @return string */ public function getStatusLabelAttribute(): string { return match($this->status) { 'on_sale' => '在售', 'off_sale' => '下架', 'deleted' => '已删除', default => '未知', }; } /** * 获取同步状态标签 * * @return string */ public function getSyncStatusLabelAttribute(): string { return match($this->sync_status) { 'pending' => '待同步', 'syncing' => '同步中', 'synced' => '已同步', 'failed' => '同步失败', default => '未知', }; } }