feat: refactor cart and bundle handling to support Buyable interface for improved flexibility
This commit is contained in:
@@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
use App\Domains\Shared\Contracts\Stockable;
|
||||
use App\Domains\Shared\Contracts\Buyable;
|
||||
|
||||
#[Fillable([
|
||||
'tenant_codigo',
|
||||
@@ -18,7 +18,7 @@ use App\Domains\Shared\Contracts\Stockable;
|
||||
'descripcion',
|
||||
'precio',
|
||||
])]
|
||||
class Bundle extends Model implements Stockable
|
||||
class Bundle extends Model implements Buyable
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -49,6 +49,16 @@ class Bundle extends Model implements Stockable
|
||||
return $this->hasMany(BundleItem::class, 'bundle_id');
|
||||
}
|
||||
|
||||
public function getPrice(): float
|
||||
{
|
||||
return (float) $this->precio;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->nombre ?? 'Bundle';
|
||||
}
|
||||
|
||||
public function incrementRealStock(int $amount): void
|
||||
{
|
||||
if ($amount < 0) {
|
||||
|
||||
Reference in New Issue
Block a user