'int', 'pos' => 'int', 'active' => 'bool', 'default' => 'bool', 'show_on' => 'array', ]; protected $fillable = [ 'name', 'short', 'show_at', 'show_on', 'max_price', 'pos', 'default', 'active' ]; public function getShowAtType(){ return isset(Type::$payShowATs[$this->show_at]) ? Type::$payShowATs[$this->show_at] : '-'; } public function getShowOnTypes(){ $ret = []; if($this->show_on){ foreach($this->show_on as $show){ $ret[] = isset(Type::$payShowONs[$show]) ? Type::$payShowONs[$show] : '-'; } } return $ret; } public static function getDefaultAsArray($short=false){ return PaymentMethod::where('active', true)->where('default', true)->pluck('id'); } public function setMaxPriceAttribute($value) { $this->attributes['max_price'] = $value ? Util::reFormatNumber($value) : null; } public function getFormattedMaxPrice() { return isset($this->attributes['max_price']) ? Util::formatNumber($this->attributes['max_price']) : ""; } /** * @param $short //PP FNC VOR CC SB ... * @param $user_payment_methods //PaymentMethod [] IDs * @param $total //Full price */ public static function isShowPaymentMethod($short, $user_payment_methods, $total = 0){ $payment_method = PaymentMethod::whereShort($short)->first(); if($payment_method && $payment_method->active){ if(in_array($payment_method->id, $user_payment_methods)){ if($total > 0 && $payment_method->max_price > 0){ if($payment_method->max_price >= $total){ return true; } }else{ return true; } } } return false; } }