"bezahlt", 'appointed' => "offen", 'failed' => "abbruch", ]; protected $txaction_color = [ 'paid' => "success", 'appointed' => "warning", 'failed' => "danger", ]; 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'); } //can null public function auth_user() { return $this->belongsTo('App\User','auth_user_id'); } public function user_history() { return $this->hasOne('App\Models\UserHistory','shopping_order_id')->latest(); } 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 setUserHistoryValue($values = []){ if($user_history = $this->user_history){ foreach ($values as $key=>$val){ $user_history->{$key} = $val; } $user_history->save(); } } 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, ',', '.'); } public function getFormattedTxaction(){ if($this->txaction && isset($this->txaction_text[$this->txaction])){ return $this->txaction_text[$this->txaction]; } return "not"; } public function getFormattedTxactionColor(){ if($this->txaction && isset($this->txaction_color[$this->txaction])){ return $this->txaction_color[$this->txaction]; } return "danger"; } }