mivita/app/Models/ShoppingOrderItem.php
2020-06-12 14:46:51 +02:00

71 lines
No EOL
2.6 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\ShoppingOrderItem
*
* @property int $id
* @property int $shopping_order_id
* @property string|null $row_id
* @property int $product_id
* @property int|null $qty
* @property float|null $price
* @property string|null $slug
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Product $product
* @property-read \App\Models\ShoppingOrder $shopping_order
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereQty($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereRowId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereUpdatedAt($value)
* @mixin \Eloquent
*/
class ShoppingOrderItem extends Model
{
protected $table = 'shopping_order_items';
use SoftDeletes;
protected $dates = ['deleted_at'];
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, ',', '.');
}
}