59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class OrderItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'order__order_item';
|
|
protected $guarded = [];
|
|
public $timestamps = false;
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(Order::class, 'order_id');
|
|
}
|
|
|
|
public function addons()
|
|
{
|
|
return $this->hasMany(OrderAddon::class, 'order_item_id');
|
|
}
|
|
|
|
|
|
public function getProductAttribute()
|
|
{
|
|
if ($this->product_id) {
|
|
return Product::find($this->product_id);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Relationship: OrderItem belongs to Product (new system)
|
|
*/
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class, 'product_id');
|
|
}
|
|
|
|
/**
|
|
* Relationship: OrderItem has pricing info
|
|
*/
|
|
public function pricing()
|
|
{
|
|
return $this->belongsTo(ProductPricings::class, 'product_pricing_id');
|
|
}
|
|
|
|
|
|
|
|
public function os()
|
|
{
|
|
return $this->belongsTo(Os::class, 'os_id');
|
|
|
|
}
|
|
}
|