43 lines
827 B
PHP
43 lines
827 B
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()
|
|
{
|
|
return match ($this->product_type) {
|
|
3 => Hosting::find($this->product_id),
|
|
4 => Vps::find($this->product_id),
|
|
default => null,
|
|
};
|
|
}
|
|
|
|
|
|
|
|
public function os()
|
|
{
|
|
return $this->belongsTo(Os::class, 'os_id');
|
|
|
|
}
|
|
}
|