'integer', 'supplier_id' => 'integer', 'shelf_life' => 'integer', 'stock' => 'integer', 'sort' => 'integer', 'status' => 'integer', ]; public function images(): Attribute { return Attribute::make( get: function($value){ if (empty($value)) { return collect(); } $ids = explode(',', $value); return SysFileModel::whereIn('id', $ids)->get(); }, set: fn ($value) => is_array($value) ? implode(',', $value) : $value, ); } /** * 所属分类 */ public function category(): BelongsTo { return $this->belongsTo(ProductCategoryModel::class, 'category_id', 'id'); } /** * 供货供应商 */ public function supplier(): BelongsTo { return $this->belongsTo(SupplierModel::class, 'supplier_id', 'id'); } /** * 多等级价格(同一商品按客户等级定价) */ public function prices(): HasMany { return $this->hasMany(ProductPriceModel::class, 'product_id', 'id'); } }