47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Bundle\Models;
|
|
|
|
use App\Domains\Catalog\Models\ProductVariant;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'bundle_id',
|
|
'producto_variante_id',
|
|
'cantidad',
|
|
])]
|
|
class BundleItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'bundle_items';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'bundle_id' => 'integer',
|
|
'producto_variante_id' => 'integer',
|
|
'cantidad' => 'integer',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Bundle, $this>
|
|
*/
|
|
public function bundle(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Bundle::class, 'bundle_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<ProductVariant, $this>
|
|
*/
|
|
public function variant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductVariant::class, 'producto_variante_id');
|
|
}
|
|
}
|