'int', 'pos' => 'int', 'active' => 'bool', 'default' => 'bool', ]; protected $fillable = [ 'name', 'short', 'show_at', 'max_price', 'pos', 'default', 'active' ]; public static $showATs = [ 0 => 'Nur Kunden Shop', 1 => 'Nur Vertriebspartner Shop', 2 => 'Kunden + Vertriebspartner Shop', 3 => 'Nur Reg/Mitgliedschaft Vertriebspartner', 4 => 'Kunden + Vertriebspartner Shop + Reg/Mitgliedschaft', 5 => 'Vertriebspartner Shop + Reg/Mitgliedschaft', 9 => 'überall', ]; public function getShowAtType(){ return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-'; } 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($payment_method->max_price > 0){ if($payment_method->max_price >= $total){ return true; } }else{ return true; } } } return false; } }