You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
willaengine/app/OrderItem.php

52 lines
1.1 KiB

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class OrderItem extends Model
{
protected $fillable = ['order_id', 'shipping_method_id','quantity','payable_id','payable_type', 'price', 'details', 'auction_id', 'gift_id'];
public function auction()
{
return $this->belongsTo('App\Auction');
}
public function business_item_variation()
{
return $this->belongsTo('App\BusinessItemVariation');
}
public function order()
{
return $this->belongsTo('App\Order');
}
public function getCreatedAtAttribute($date)
{
return \Morilog\Jalali\jDate::forge($date)->format('datetime');
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details']);
}
public function getAllPriceAttribute()
{
return $this->attributes['price'] * $this->attributes['quantity'];
}
public function payable()
{
return $this->morphTo();
}
}