Skip to content

Commit ac68a37

Browse files
committed
Style fixes
1 parent 31bb878 commit ac68a37

7 files changed

Lines changed: 26 additions & 15 deletions

File tree

app/Http/Controllers/PortPopupController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* PortPopupController.php
45
*

app/Http/Controllers/PortsController.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function index(Request $request, ?string $view = null, ?string $graph = n
3939
'media',
4040
'descr',
4141
'device',
42-
])
42+
]),
4343
]);
4444

4545
$errors = $request->boolean('errors');
@@ -102,7 +102,7 @@ public function index(Request $request, ?string $view = null, ?string $graph = n
102102
public function purge(Request $request): JsonResponse
103103
{
104104
$request->validate([
105-
'purge' => ['required', 'regex:/^(\d+|all)$/']
105+
'purge' => ['required', 'regex:/^(\d+|all)$/'],
106106
]);
107107

108108
$purge = $request->input('purge');
@@ -127,7 +127,6 @@ public function purge(Request $request): JsonResponse
127127
return response()->json(['message' => 'Successfully purged port ID ' . ((int) $purge)]);
128128
}
129129

130-
131130
private function filterFields(): array
132131
{
133132
return [
@@ -155,7 +154,7 @@ private function filterFields(): array
155154
'options' => [
156155
'up',
157156
'down',
158-
'shutdown'
157+
'shutdown',
159158
],
160159
],
161160
[
@@ -229,7 +228,7 @@ private function getPorts(string $view, int $perPage, string $sort): ?LengthAwar
229228
->with(['device' => fn ($query) => $query->select(['device_id', 'hostname', 'sysName', 'display', 'ip', 'overwrite_ip'])])
230229
->isValid()
231230
->whereHas('device') // a device is required for graphs to work
232-
->when(request()->array('filter'), fn(Builder $query, $filters) => $query->applyFilters($filters));
231+
->when(request()->array('filter'), fn (Builder $query, $filters) => $query->applyFilters($filters));
233232

234233
$portsQuery = match ($sort) {
235234
'traffic' => $portsQuery->orderByRaw('ifInOctets_rate + ifOutOctets_rate desc'),

app/Http/Controllers/Select/PortFieldController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ protected function searchFields($request)
7979
protected function baseQuery($request)
8080
{
8181
$this->idField = $request->string('field');
82+
8283
return Port::hasAccess($request->user())
8384
->whereNotNull($this->idField)
8485
->select($this->idField)
@@ -94,7 +95,7 @@ public function formatItem($model)
9495

9596
return [
9697
'id' => $value,
97-
'text' => match($field) {
98+
'text' => match ($field) {
9899
'ifSpeed' => Number::formatSi($value, suffix: 'bps'),
99100
'ifType' => Rewrite::normalizeIfType($value),
100101
default => $value,

app/Http/Controllers/Table/PortsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ function ($attribute, $value, $fail) {
6060
$allowedOps = ['eq', 'neq', 'contains', 'starts_with', 'gt', 'lt', 'in', 'not_in', 'is_empty'];
6161
$operator = array_key_first($value);
6262

63-
if (!in_array($operator, $allowedOps)) {
63+
if (! in_array($operator, $allowedOps)) {
6464
$fail("The operator '{$operator}' is not supported.");
6565
}
66-
}
66+
},
6767
],
6868
'filter.*.*' => ['nullable', 'max:255'],
6969
];
@@ -114,7 +114,7 @@ protected function baseQuery($request)
114114
$query = Port::hasAccess($request->user())
115115
->with(['device', 'device.location'])
116116
->leftJoin('devices', 'ports.device_id', 'devices.device_id')
117-
->when($request->array('filter'), fn($q, $filter) => $q->applyFilters($filter))
117+
->when($request->array('filter'), fn ($q, $filter) => $q->applyFilters($filter))
118118
->unless($request->has('filter.deleted'), function ($q) use ($request) {
119119
return $q->where('ports.deleted', $request->input('deleted', 0));
120120
})

app/Http/Controllers/UserPreferencesController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ public function store(Request $request)
134134
return response()->json(['status' => 'success']);
135135
}
136136

137-
public function update(Request $request, string $preference) {
137+
public function update(Request $request, string $preference)
138+
{
138139
$request->validate([
139140
'name' => ['required', 'string'],
140141
'filters' => ['array'],

app/Models/Port.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function filterSearch(Builder $query, string $op, mixed $value, array $co
391391

392392
$operator = $config['operator'] ?? '=';
393393

394-
$query->where(function($q) use ($value, $operator) {
394+
$query->where(function ($q) use ($value, $operator) {
395395
$q->where('ports.ifName', $operator, $value)
396396
->orWhere('ifAlias', $operator, $value)
397397
->orWhere('ifDescr', $operator, $value);
@@ -422,7 +422,7 @@ public function filterGroup(Builder $query, string $op, mixed $value): void
422422

423423
$has = match ($op) {
424424
'neq', 'not_in' => 'whereDoesntHave',
425-
default => 'whereHas',
425+
default => 'whereHas',
426426
};
427427

428428
$query->{$has}('groups', function ($q) use ($op, $ids) {

app/Models/Traits/Filterable.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Filterable.php
45
*
@@ -65,11 +66,17 @@ public function scopeApplyFilters(Builder $query, array $filters): Builder
6566
$allowed = $this->filterable ?? [];
6667

6768
foreach ($filters as $field => $operators) {
68-
if (!in_array($field, $allowed)) continue;
69-
if (!is_array($operators)) continue;
69+
if (! in_array($field, $allowed)) {
70+
continue;
71+
}
72+
if (! is_array($operators)) {
73+
continue;
74+
}
7075

7176
foreach ($operators as $op => $value) {
72-
if (!isset($this->operatorMap[$op])) continue;
77+
if (! isset($this->operatorMap[$op])) {
78+
continue;
79+
}
7380

7481
$config = $this->operatorMap[$op];
7582
$method = $config['method'];
@@ -105,12 +112,14 @@ protected function applyQueryLogic($query, $field, $op, $value, $config, $method
105112
{
106113
if (in_array($op, ['is_empty', 'is_not_empty'])) {
107114
$query->$method($field);
115+
108116
return;
109117
}
110118

111119
if (in_array($op, ['in', 'not_in'])) {
112120
$values = is_array($value) ? $value : explode(',', $value);
113121
$query->$method($field, $values);
122+
114123
return;
115124
}
116125

0 commit comments

Comments
 (0)