You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
PHTML
53 lines
1.4 KiB
PHTML
2 years ago
|
<?php
|
||
|
|
||
|
namespace App\Scopes;
|
||
|
|
||
|
trait PlayerRoleScopes
|
||
|
{
|
||
|
public function scopeOfConditions($query, $params)
|
||
|
{
|
||
|
if (!empty($params['server_id'])) {
|
||
|
$query->where('server_id', $params['server_id']);
|
||
|
}
|
||
|
if (!empty($params['sdk_version'])) {
|
||
|
$query->where('sdk_version', $params['sdk_version']);
|
||
|
}
|
||
|
if (!empty($params['game_id'])) {
|
||
|
$query->where('game_id', $params['game_id']);
|
||
|
}
|
||
|
if (!empty($params['role_name'])) {
|
||
|
$query->where('role_name', $params['role_name']);
|
||
|
}
|
||
|
if (!empty($params['server_name'])) {
|
||
|
$query->where('server_name', $params['server_name']);
|
||
|
}
|
||
|
if (!empty($params['user_account'])) {
|
||
|
$query->where('user_account', $params['user_account']);
|
||
|
}
|
||
|
if (!empty($params['role_id'])) {
|
||
|
$query->where('role_id', $params['role_id']);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function scopeRangeRoleLevel($query, ?array $roleLevelRange)
|
||
|
{
|
||
|
if (is_null($roleLevelRange)) {
|
||
|
return $query;
|
||
|
}
|
||
|
$min = $roleLevelRange[0] ?? null;
|
||
|
$min == '' ? null : $min;
|
||
|
|
||
|
$max = $roleLevelRange[1] ?? null;
|
||
|
$max == '' ? null : $max;
|
||
|
|
||
|
if (!is_null($min)) {
|
||
|
$query->where('role_level', '>=', $min);
|
||
|
}
|
||
|
|
||
|
if (!is_null($max)) {
|
||
|
$query->where('role_level', '<=', $max);
|
||
|
}
|
||
|
|
||
|
return $query;
|
||
|
}
|
||
|
}
|