feat: implement Bundle and BundleItem models, migrations, and polymorphic relationships for cart and purchase items
This commit is contained in:
@@ -10,7 +10,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable([
|
||||
'compra_id',
|
||||
'producto_variante_id',
|
||||
'buyable_id',
|
||||
'buyable_type',
|
||||
'cantidad',
|
||||
'precio_unitario',
|
||||
'discount_total',
|
||||
@@ -27,7 +28,8 @@ class PurchaseItem extends Model
|
||||
{
|
||||
return [
|
||||
'compra_id' => 'integer',
|
||||
'producto_variante_id' => 'integer',
|
||||
'buyable_id' => 'integer',
|
||||
'buyable_type' => 'string',
|
||||
'cantidad' => 'integer',
|
||||
'precio_unitario' => 'decimal:2',
|
||||
'discount_total' => 'decimal:2',
|
||||
@@ -45,10 +47,10 @@ class PurchaseItem extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<ProductVariant, $this>
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function variant(): BelongsTo
|
||||
public function buyable()
|
||||
{
|
||||
return $this->belongsTo(ProductVariant::class, 'producto_variante_id');
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user