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/ShoppingCart.php

49 lines
1.1 KiB

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Traites\GetDateAttributesTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
class ShoppingCart extends Model
{
use GetDateAttributesTrait, SoftDeletes;
protected $fillable = ['quantity', 'user_id', 'payable_id', 'payable_type', 'details', 'business_id'];
public function batch()
{
return $this->belongsTo('App\BatchShoppingCart');
}
public function getDetailsAttribute()
{
return json_decode($this->attributes['details'], true);
}
public function setDetailsAttribute($value)
{
$this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function user()
{
return $this->belongsTo('App\User');
}
public function business_item_variation()
{
return $this->belongsTo('App\BusinessItemVariation');
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function payable()
{
return $this->morphTo();
}
}