'array']; protected $fillable = [ 'next_id', 'name', 'margin', 'margin_shop', 'qual_kp', 'qual_pp', 'growth_bonus', 'pr_line_1', 'pr_line_2', 'pr_line_3', 'pr_line_4', 'pr_line_5', 'pr_line_6', 'pr_line_7', 'pr_line_8', 'paylines', 'pos', 'active', 'default', ]; public function next_user_level() { return $this->belongsTo('App\Models\UserLevel', 'next_id', 'id'); } public function getNextUserLevels(){ //$ret = [0=>'Keinen']; $ret = UserLevel::where('active', true)->where('id', '!=', $this->id)->orderBy('pos', 'asc')->get()->pluck('name', 'id')->toArray(); return array_add($ret, 0, '-> Keinen Karriere Level'); } public function setPosAttribute($value){ $this->attributes['pos'] = is_numeric($value) ? $value : null; } public function setGrowthBonusAttribute($value) { $this->attributes['growth_bonus'] = $value !== null ? Util::reFormatNumber($value) : null; } public function getFormattedGrowthBonus() { return isset($this->attributes['growth_bonus']) ? Util::formatNumber($this->attributes['growth_bonus'],1) : ""; } public function getFormattedMargin() { return isset($this->attributes['margin']) ? $this->attributes['margin'] : ""; } public function getLang($key) { $lang = \App::getLocale(); if ($lang === 'de') { return $this->{$key}; } $trans = $this->getTrans($key, $lang); if (!$trans || $trans == '') { return $this->{$key}; } return $trans; } public function getTrans($key, $lang) { $key = 'trans_' . $key; if (!empty($this->{$key}[$lang])) { return $this->{$key}[$lang]; } } public function getTranNames() { $ret = ""; foreach ((array) $this->trans_name as $value){ $ret .= $value.', '; } return rtrim($ret, ', '); } }