82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ShoppingOrder extends Model
|
|
{
|
|
protected $table = 'shopping_orders';
|
|
|
|
protected $fillable = [
|
|
'shopping_user_id',
|
|
'country_id',
|
|
'user_shop_id',
|
|
'total',
|
|
'shipping',
|
|
'subtotal',
|
|
'tax_rate',
|
|
'tax',
|
|
'total_shipping',
|
|
'weight',
|
|
];
|
|
|
|
|
|
public function shopping_user()
|
|
{
|
|
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
|
|
}
|
|
|
|
public function country()
|
|
{
|
|
return $this->belongsTo('App\Models\Country','country_id');
|
|
}
|
|
|
|
public function user_shop()
|
|
{
|
|
return $this->belongsTo('App\Models\UserShop','user_shop_id');
|
|
}
|
|
|
|
public function shopping_order_items(){
|
|
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
|
|
}
|
|
|
|
public function shopping_payments(){
|
|
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');
|
|
}
|
|
|
|
|
|
public function _format_number($value)
|
|
{
|
|
return preg_replace("/[^0-9,]/", "", $value);
|
|
}
|
|
|
|
|
|
public function getFormattedShipping()
|
|
{
|
|
if (\App::getLocale() == "en") {
|
|
return number_format($this->attributes['shipping'], 2, '.', ',');
|
|
}
|
|
return number_format($this->attributes['shipping'], 2, ',', '.');
|
|
}
|
|
|
|
public function getFormattedTotalShipping()
|
|
{
|
|
if (\App::getLocale() == "en") {
|
|
return number_format($this->attributes['total_shipping'], 2, '.', ',');
|
|
}
|
|
return number_format($this->attributes['total_shipping'], 2, ',', '.');
|
|
}
|
|
|
|
|
|
public function getFormattedPrice()
|
|
{
|
|
if (\App::getLocale() == "en") {
|
|
return number_format($this->attributes['price'], 2, '.', ',');
|
|
}
|
|
return number_format($this->attributes['price'], 2, ',', '.');
|
|
}
|
|
|
|
|
|
|
|
}
|