Use more standardized phpcs
This commit is contained in:
parent
a043071e3c
commit
c449ca5155
493 changed files with 1116 additions and 3903 deletions
|
@ -12,16 +12,12 @@ class AdminServerFilter implements Filter
|
|||
* A multi-column filter for the servers table that allows an administrative user to search
|
||||
* across UUID, name, owner username, and owner email.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $value
|
||||
* @param string $property
|
||||
*/
|
||||
public function __invoke(Builder $query, $value, string $property)
|
||||
{
|
||||
if ($query->getQuery()->from !== 'servers') {
|
||||
throw new BadMethodCallException(
|
||||
'Cannot use the AdminServerFilter against a non-server model.'
|
||||
);
|
||||
throw new BadMethodCallException('Cannot use the AdminServerFilter against a non-server model.');
|
||||
}
|
||||
$query
|
||||
->select('servers.*')
|
||||
|
|
|
@ -20,16 +20,12 @@ class MultiFieldServerFilter implements Filter
|
|||
* search across multiple columns. This allows us to provide a very generic search ability for
|
||||
* the frontend.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $value
|
||||
* @param string $property
|
||||
*/
|
||||
public function __invoke(Builder $query, $value, string $property)
|
||||
{
|
||||
if ($query->getQuery()->from !== 'servers') {
|
||||
throw new BadMethodCallException(
|
||||
'Cannot use the MultiFieldServerFilter against a non-server model.'
|
||||
);
|
||||
throw new BadMethodCallException('Cannot use the MultiFieldServerFilter against a non-server model.');
|
||||
}
|
||||
|
||||
if (preg_match(self::IPV4_REGEX, $value) || preg_match('/^:\d{1,5}$/', $value)) {
|
||||
|
@ -42,12 +38,12 @@ class MultiFieldServerFilter implements Filter
|
|||
$parts = explode(':', $value);
|
||||
|
||||
$builder->when(
|
||||
! Str::startsWith($value, ':'),
|
||||
!Str::startsWith($value, ':'),
|
||||
// When the string does not start with a ":" it means we're looking for an IP or IP:Port
|
||||
// combo, so use a query to handle that.
|
||||
function (Builder $builder) use ($parts) {
|
||||
$builder->orWhere('allocations.ip', $parts[0]);
|
||||
if (! is_null($parts[1] ?? null)) {
|
||||
if (!is_null($parts[1] ?? null)) {
|
||||
$builder->where('allocations.port', 'LIKE', "{$parts[1]}%");
|
||||
}
|
||||
},
|
||||
|
|
Reference in a new issue