update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
133
dev/app-bak/Models/UserLevel.php
Normal file
133
dev/app-bak/Models/UserLevel.php
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\UserLevel as ModelsUserLevel;
|
||||
|
||||
/**
|
||||
* App\Models\UserLevel
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property float|null $margin
|
||||
* @property int|null $pos
|
||||
* @property int $active
|
||||
* @property int $default
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereDefault($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereMargin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
|
||||
* @property int|null $next_id
|
||||
* @property int|null $margin_shop
|
||||
* @property int|null $qual_kp
|
||||
* @property int|null $qual_pp
|
||||
* @property string|null $growth_bonus
|
||||
* @property int|null $pr_line_1
|
||||
* @property int|null $pr_line_2
|
||||
* @property int|null $pr_line_3
|
||||
* @property int|null $pr_line_4
|
||||
* @property int|null $pr_line_5
|
||||
* @property int|null $pr_line_6
|
||||
* @property int|null $pr_line_7
|
||||
* @property int|null $pr_line_8
|
||||
* @property-read UserLevel|null $next_user_level
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereGrowthBonus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereMarginShop($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereNextId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine1($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine2($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine3($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine4($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine5($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine6($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualKp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualTp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine7($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine8($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualPp($value)
|
||||
* @property int|null $paylines
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePaylines($value)
|
||||
* @property string|null $trans_name
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransUserLevel> $translations
|
||||
* @property-read int|null $translations_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransName($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserLevel extends Model
|
||||
{
|
||||
protected $table = 'user_levels';
|
||||
|
||||
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 translations()
|
||||
{
|
||||
return $this->hasMany(TransUserLevel::class, 'user_level_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 [0 => '-> Keinen Karriere Level'] + $ret;
|
||||
}
|
||||
|
||||
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']) ? Util::formatNumber($this->attributes['margin'], 1) : "";
|
||||
}
|
||||
|
||||
public function getFormattedMarginShop()
|
||||
{
|
||||
return isset($this->attributes['margin_shop']) ? Util::formatNumber($this->attributes['margin_shop'], 1) : "";
|
||||
}
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
if ($lang == 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
return $trans != '' ? $trans : $this->{$key};
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
|
||||
return $trans ? $trans->value : '';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue