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.
67 lines
1.5 KiB
67 lines
1.5 KiB
5 years ago
|
<?php
|
||
|
|
||
|
namespace App;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
use App\Appended\Traites\GetDateAttributesTrait;
|
||
|
|
||
|
|
||
|
class Order extends Model
|
||
|
{
|
||
|
use GetDateAttributesTrait;
|
||
|
|
||
|
protected $fillable = ['transaction_id','description', 'status', 'shipping_free', 'address_id', 'buyer_id','business_id', 'shipping_method','status_logs', 'details'];
|
||
|
|
||
|
|
||
|
public function address ()
|
||
|
{
|
||
|
return $this->belongsTo('App\Address');
|
||
|
}
|
||
|
|
||
|
public function buyer ()
|
||
|
{
|
||
|
return $this->belongsTo('App\User', 'buyer_id');
|
||
|
}
|
||
|
|
||
|
public function business ()
|
||
|
{
|
||
|
return $this->belongsTo('App\Business', 'business_id');
|
||
|
}
|
||
|
|
||
|
public function transactions ()
|
||
|
{
|
||
|
return $this->belongsTo('App\Transaction');
|
||
|
}
|
||
|
|
||
|
public function order_items()
|
||
|
{
|
||
|
return $this->hasMany('App\OrderItem');
|
||
|
}
|
||
|
|
||
|
public function setStatusLogsAttribute($value)
|
||
|
{
|
||
|
$this->attributes['status_logs'] = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||
|
}
|
||
|
|
||
|
public function getStatusLogsAttribute()
|
||
|
{
|
||
|
return json_decode($this->attributes['status_logs']);
|
||
|
}
|
||
|
|
||
|
public function setDetailsAttribute($value)
|
||
|
{
|
||
|
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||
|
}
|
||
|
|
||
|
public function getDetailsAttribute()
|
||
|
{
|
||
|
return json_decode($this->attributes['details']);
|
||
|
}
|
||
|
|
||
|
|
||
|
// public function getCreatedAtAttribute($date)
|
||
|
// {
|
||
|
// return \Morilog\Jalali\jDate::forge($date)->format('datetime');
|
||
|
// }
|
||
|
}
|