Update source into github
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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');
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user