08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
|
|
@ -11,7 +11,6 @@ use App\Models\UserLevel as ModelsUserLevel;
|
|||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property array|null $trans_name
|
||||
* @property float|null $margin
|
||||
* @property int|null $pos
|
||||
* @property int $active
|
||||
|
|
@ -28,7 +27,6 @@ use App\Models\UserLevel as ModelsUserLevel;
|
|||
* @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 whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
|
||||
* @property int|null $next_id
|
||||
* @property int|null $margin_shop
|
||||
|
|
@ -58,14 +56,18 @@ use App\Models\UserLevel as ModelsUserLevel;
|
|||
* @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 $casts = ['trans_name' => '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',
|
||||
];
|
||||
|
|
@ -76,6 +78,11 @@ class UserLevel extends Model
|
|||
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();
|
||||
|
|
@ -98,37 +105,29 @@ class UserLevel extends Model
|
|||
|
||||
public function getFormattedMargin()
|
||||
{
|
||||
return isset($this->attributes['margin']) ? $this->attributes['margin'] : "";
|
||||
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') {
|
||||
if ($lang == 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
if (!$trans || $trans == '') {
|
||||
return $this->{$key};
|
||||
}
|
||||
return $trans;
|
||||
return $trans != '' ? $trans : $this->{$key};
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
|
||||
return $trans ? $trans->value : '';
|
||||
}
|
||||
|
||||
public function getTranNames()
|
||||
{
|
||||
$ret = "";
|
||||
foreach ((array) $this->trans_name as $value){
|
||||
$ret .= $value.', ';
|
||||
}
|
||||
return rtrim($ret, ', ');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue