mivita/app/Models/ShoppingOrderItem.php
2019-02-28 18:09:54 +01:00

39 lines
No EOL
806 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ShoppingOrderItem extends Model
{
protected $table = 'shopping_order_items';
protected $fillable = [
'shopping_order_id',
'row_id',
'product_id',
'qty',
'price',
'slug',
];
public function shopping_order()
{
return $this->belongsTo('App\Models\ShoppingOrder','shopping_order_id');
}
public function product()
{
return $this->belongsTo('App\Models\Product','product_id');
}
public function getFormattedPrice()
{
if (\App::getLocale() == "en") {
return number_format($this->attributes['price'], 2, '.', ',');
}
return number_format($this->attributes['price'], 2, ',', '.');
}
}