Skip to content

Commit daa6b9a

Browse files
committed
Apply fixes from StyleCI
1 parent 2525fe1 commit daa6b9a

30 files changed

+104
-108
lines changed

src/Actions/ActionEvent.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public function target()
6969
};
7070

7171
return $this->morphTo('target', 'target_type', 'target_id')
72-
->constrain(
73-
collect(Nova::$resources)
74-
->filter(static fn ($resource) => $resource::softDeletes())
75-
->mapWithKeys(static fn ($resource) => [$resource::$model => $queryWithTrashed])
76-
->all()
77-
)->when(true, static fn ($query) => $query->hasMacro('withTrashed') ? $queryWithTrashed($query) : $query);
72+
->constrain(
73+
collect(Nova::$resources)
74+
->filter(static fn ($resource) => $resource::softDeletes())
75+
->mapWithKeys(static fn ($resource) => [$resource::$model => $queryWithTrashed])
76+
->all()
77+
)->when(true, static fn ($query) => $query->hasMacro('withTrashed') ? $queryWithTrashed($query) : $query);
7878
}
7979

8080
/**
@@ -348,9 +348,9 @@ public static function prune(Collection $models, int $limit = 25): void
348348
->whereNotIn('id', static function ($query) use ($model, $limit) {
349349
$query->select('id')->fromSub(
350350
static::select('id')->orderBy('id', 'desc')
351-
->where('actionable_id', $model['actionable_id'])
352-
->where('actionable_type', $model['actionable_type'])
353-
->limit($limit)->toBase(),
351+
->where('actionable_id', $model['actionable_id'])
352+
->where('actionable_type', $model['actionable_type'])
353+
->limit($limit)->toBase(),
354354
'action_events_temp'
355355
);
356356
})->delete();
@@ -363,7 +363,7 @@ public static function prune(Collection $models, int $limit = 25): void
363363
public static function markBatchAsRunning(string $batchId): int
364364
{
365365
return static::where('batch_id', $batchId)
366-
->whereNotIn('status', ['finished', 'failed'])->update([
366+
->whereNotIn('status', ['finished', 'failed'])->update([
367367
'status' => 'running',
368368
]);
369369
}
@@ -374,7 +374,7 @@ public static function markBatchAsRunning(string $batchId): int
374374
public static function markBatchAsFinished(string $batchId): int
375375
{
376376
return static::where('batch_id', $batchId)
377-
->whereNotIn('status', ['finished', 'failed'])->update([
377+
->whereNotIn('status', ['finished', 'failed'])->update([
378378
'status' => 'finished',
379379
]);
380380
}
@@ -397,7 +397,7 @@ public static function markAsFinished(string $batchId, $model): int
397397
public static function markBatchAsFailed(string $batchId, Throwable|string|null $e = null): int
398398
{
399399
return static::where('batch_id', $batchId)
400-
->whereNotIn('status', ['finished', 'failed'])->update([
400+
->whereNotIn('status', ['finished', 'failed'])->update([
401401
'status' => 'failed',
402402
'exception' => $e ? (string) $e : '',
403403
]);
@@ -421,9 +421,9 @@ public static function markAsFailed(string $batchId, $model, Throwable|string|nu
421421
public static function updateStatus(string $batchId, $model, string $status, Throwable|string|null $e = null): int
422422
{
423423
return static::where('batch_id', $batchId)
424-
->where('model_type', $model->getMorphClass())
425-
->where('model_id', $model->getKey())
426-
->update(['status' => $status, 'exception' => (string) $e]);
424+
->where('model_type', $model->getMorphClass())
425+
->where('model_id', $model->getKey())
426+
->update(['status' => $status, 'exception' => (string) $e]);
427427
}
428428

429429
/**

src/Actions/CallQueuedAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function handle()
5656
}
5757

5858
return $action->withActionBatchId($this->actionBatchId)
59-
->{$this->method}($this->fields, $this->models);
59+
->{$this->method}($this->fields, $this->models);
6060
});
6161
}
6262

src/Auth/Actions/LoginViewResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function toResponse($request)
1919
$initialYear = config('app.initialyear', date('Y'));
2020
$currentYear = date('Y');
2121
$years = $initialYear <= $currentYear ? range($initialYear, $currentYear) : [];
22+
2223
return Inertia::render('Nova.Login', [
2324
'username' => Nova::fortify()->username,
2425
'email' => Nova::fortify()->email,

src/Auth/Actions/LogoutResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Http\JsonResponse;
66
use Laravel\Fortify\Contracts\LogoutResponse as Responsable;
7-
use Laravel\Nova\Nova;
87

98
class LogoutResponse implements Responsable
109
{

src/Concerns/HandlesRoutes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public static function url(?string $url = null): string
4646
public static function router(?array $middleware = null, ?string $prefix = null): RouteRegistrar
4747
{
4848
return Route::domain(config('nova.domain', null))
49-
->prefix(static::url($prefix))
50-
->middleware($middleware ?? config('nova.middleware', []));
49+
->prefix(static::url($prefix))
50+
->middleware($middleware ?? config('nova.middleware', []));
5151
}
5252

5353
/**

src/Fields/DetachesPivotModels.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ protected function detachmentCallback(): callable
2626
$pivotFields = $resource->resolvePivotFields($request, $request->resource);
2727

2828
$pivotFields->whereInstanceOf(Deletable::class)
29-
->filter->isPrunable()
30-
->each(static function ($field) use ($request, $pivot) {
31-
/** @var \Laravel\Nova\Fields\Field&\Laravel\Nova\Contracts\Deletable $field */
32-
DeleteField::forRequest($request, $field, $pivot)->save();
33-
});
29+
->filter->isPrunable()
30+
->each(static function ($field) use ($request, $pivot) {
31+
/** @var \Laravel\Nova\Fields\Field&\Laravel\Nova\Contracts\Deletable $field */
32+
DeleteField::forRequest($request, $field, $pivot)->save();
33+
});
3434

3535
$pivot->delete();
3636
}

src/Fields/HasOne.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ public function __construct($name, ?string $attribute = null, ?string $resource
121121

122122
if ($this->ofManyRelationship === false && $request->viaRelationship === $this->attribute && $request->viaResourceId) {
123123
$parent = $parentResource::newModel()
124-
->with($this->attribute)
125-
->find($request->viaResourceId);
124+
->with($this->attribute)
125+
->find($request->viaResourceId);
126126

127127
return model_exists($parent->{$this->attribute});
128128
}
129129

130130
return false;
131131
})->showOnCreating(static fn ($request) => ! \in_array($request->relationshipType, ['hasOne', 'morphOne']))
132-
->showOnUpdating(static fn ($request) => ! \in_array($request->relationshipType, ['hasOne', 'morphOne']))
133-
->nullable();
132+
->showOnUpdating(static fn ($request) => ! \in_array($request->relationshipType, ['hasOne', 'morphOne']))
133+
->nullable();
134134
}
135135

136136
/**

src/Fields/ID.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public static function forResource(Resource $resource): ?static
6666
/** @phpstan-ignore argument.templateType */
6767
$field = transform(
6868
$resource->availableFieldsOnIndexOrDetail(app(NovaRequest::class))
69-
->whereInstanceOf(self::class)
70-
->first(),
69+
->whereInstanceOf(self::class)
70+
->first(),
7171
static fn ($field) => tap($field)->resolve($model),
7272
static fn () => model_exists($model) ? static::forModel($model) : null,
7373
);

src/Fields/MorphTo.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ protected function filterableAttribute(NovaRequest $request)
542542
protected function defaultFilterableCallback()
543543
{
544544
$morphToTypes = collect($this->morphToTypes)
545-
->pluck('type')
546-
->mapWithKeys(static fn ($type) => [$type => $type::newModel()->getMorphClass()])
547-
->all();
545+
->pluck('type')
546+
->mapWithKeys(static fn ($type) => [$type => $type::newModel()->getMorphClass()])
547+
->all();
548548

549549
return function (NovaRequest $request, $query, $value, $attribute) use ($morphToTypes) {
550550
$query->whereHasMorph(

src/Fields/MorphToMany.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ public function singularLabel(Stringable|string $singularLabel)
229229
public function asPanel(): Panel
230230
{
231231
return Panel::make($this->name, [$this])
232-
->withMeta([
233-
'prefixComponent' => true,
234-
])->withComponent('relationship-panel');
232+
->withMeta([
233+
'prefixComponent' => true,
234+
])->withComponent('relationship-panel');
235235
}
236236

237237
/**

src/Fields/Number.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ public function jsonSerialize(): array
144144
'max' => $this->max,
145145
'step' => $this->step,
146146
])->reject(static fn ($value) => \is_null($value) || (empty($value) && $value !== 0))
147-
->all());
147+
->all());
148148
}
149149
}

src/Fields/Select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function displayUsingLabels()
6767
}
6868

6969
return collect($this->serializeOptions(false))
70-
->where('value', $value)
71-
->first()['label'] ?? $value;
70+
->where('value', $value)
71+
->first()['label'] ?? $value;
7272
});
7373

7474
return $this;

src/Http/Controllers/AttachableController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ class AttachableController extends Controller
1616
public function __invoke(NovaRequest $request): array
1717
{
1818
$field = $request->newResource()
19-
->availableFields($request)
20-
->filterForManyToManyRelations()
21-
->filter(static function ($field) use ($request) {
22-
return $field->resourceName === $request->field && // @phpstan-ignore property.notFound
23-
$field->component === $request->component &&
24-
$field->attribute === $request->viaRelationship;
25-
})->first();
19+
->availableFields($request)
20+
->filterForManyToManyRelations()
21+
->filter(static function ($field) use ($request) {
22+
return $field->resourceName === $request->field && // @phpstan-ignore property.notFound
23+
$field->component === $request->component &&
24+
$field->attribute === $request->viaRelationship;
25+
})->first();
2626

2727
abort_if(\is_null($field), 404);
2828

@@ -94,8 +94,8 @@ protected function getAttachableQueryResolver(NovaRequest $request, PivotableFie
9494
$relation = $relatedModel->{$field->manyToManyRelationship}();
9595

9696
return $relation->applyDefaultPivotQuery($query)
97-
->select($relation->getRelatedPivotKeyName())
98-
->whereColumn($relation->getQualifiedRelatedKeyName(), $relation->getQualifiedRelatedPivotKeyName());
97+
->select($relation->getRelatedPivotKeyName())
98+
->whereColumn($relation->getQualifiedRelatedKeyName(), $relation->getQualifiedRelatedPivotKeyName());
9999
});
100100
};
101101
}

src/Http/Controllers/CreationPivotFieldController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function sync(ResourceCreateOrAttachRequest $request): JsonResponse
3131
return $request->query('field') === $field->attribute &&
3232
$request->query('component') === $field->dependentComponentKey();
3333
})->applyDependsOn($request)
34-
->first()
34+
->first()
3535
);
3636
}
3737
}

src/Http/Controllers/UpdatePivotFieldController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function sync(ResourceUpdateOrUpdateAttachedRequest $request): JsonRespon
3131
return $request->query('field') === $field->attribute &&
3232
$request->query('component') === $field->dependentComponentKey();
3333
})->applyDependsOn($request)
34-
->first()
34+
->first()
3535
);
3636
}
3737
}

src/Http/Middleware/HandleInertiaRequests.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Closure;
66
use Illuminate\Http\Request;
7-
use Illuminate\Support\Facades\Cache;
87
use Illuminate\Support\Facades\Config;
98
use Inertia\Inertia;
109
use Inertia\Middleware;

src/Http/Requests/LensRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ public function toResources(Collection $models): Collection
116116
$payload['actions'] = collect(
117117
$hasId === true ? array_values($lensResource->actions($this)) : []
118118
)->filter(static fn ($action) => $action->shownOnIndex() || $action->shownOnTableRow())
119-
->filter->authorizedToSee($this)
120-
->filter->authorizedToRun($this, $model)
121-
->values();
119+
->filter->authorizedToSee($this)
120+
->filter->authorizedToRun($this, $model)
121+
->values();
122122

123123
return $payload;
124124
});

src/Jobs/DeletesFields.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ protected function deleteFields(NovaRequest $request, $model, bool $skipSoftDele
2929
}
3030

3131
$request->newResourceWith($model)
32-
->deletableFields($request)
33-
->filter->isPrunable()
34-
->each(static function ($field) use ($request, $model) {
35-
DeleteField::forRequest($request, $field, $model);
36-
});
32+
->deletableFields($request)
33+
->filter->isPrunable()
34+
->each(static function ($field) use ($request, $model) {
35+
DeleteField::forRequest($request, $field, $model);
36+
});
3737
}
3838
}

src/Menu/Breadcrumb.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public static function resource(Resource|string $resourceClass): static
4444
'title' => $resourceClass->title(),
4545
])
4646
)->path('/resources/'.$resourceClass::uriKey().'/'.$resourceClass->getKey())
47-
->canSee(static fn ($request) => $resourceClass->authorizedToView($request));
47+
->canSee(static fn ($request) => $resourceClass->authorizedToView($request));
4848
}
4949

5050
return static::make(
5151
Nova::__($resourceClass::label())
5252
)->path('/resources/'.$resourceClass::uriKey())
53-
->canSee(static fn ($request) => $resourceClass::availableForNavigation($request) && $resourceClass::authorizedToViewAny($request));
53+
->canSee(static fn ($request) => $resourceClass::availableForNavigation($request) && $resourceClass::authorizedToViewAny($request));
5454
}
5555

5656
/**

src/Menu/Menu.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public function jsonSerialize(): array
9696
$request = app(NovaRequest::class);
9797

9898
return $this->items->flatten()
99-
->reject(static fn ($item) => method_exists($item, 'authorizedToSee') && ! $item->authorizedToSee($request))
100-
->values()
101-
->jsonSerialize();
99+
->reject(static fn ($item) => method_exists($item, 'authorizedToSee') && ! $item->authorizedToSee($request))
100+
->values()
101+
->jsonSerialize();
102102
}
103103
}

src/Menu/MenuSection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function dashboard(string $dashboard)
8282
return static::make(
8383
$dashboard->label()
8484
)->path('/dashboards/'.$dashboard->uriKey())
85-
->canSee(static fn ($request) => $dashboard->authorizedToSee($request));
85+
->canSee(static fn ($request) => $dashboard->authorizedToSee($request));
8686
});
8787
}
8888

@@ -97,7 +97,7 @@ public static function resource(string $resourceClass)
9797
return static::make(
9898
$resourceClass::label()
9999
)->path('/resources/'.$resourceClass::uriKey())
100-
->canSee(static fn ($request) => $resourceClass::availableForNavigation($request) && $resourceClass::authorizedToViewAny($request));
100+
->canSee(static fn ($request) => $resourceClass::availableForNavigation($request) && $resourceClass::authorizedToViewAny($request));
101101
}
102102

103103
/**

src/Metrics/Trend.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,12 @@ protected function aggregate(
392392
$wrappedColumn = $query->getQuery()->getGrammar()->wrap($column);
393393

394394
$results = $query
395-
->select(DB::raw("{$expression} as date_result, {$function}({$wrappedColumn}) as aggregate"))
396-
->tap(fn ($query) => $this->applyFilterQuery($request, $query))
397-
->whereBetween($dateColumn, $this->formatQueryDateBetween([$startingDate, $endingDate]))
398-
->groupBy(DB::raw($expression))
399-
->orderBy('date_result')
400-
->get();
395+
->select(DB::raw("{$expression} as date_result, {$function}({$wrappedColumn}) as aggregate"))
396+
->tap(fn ($query) => $this->applyFilterQuery($request, $query))
397+
->whereBetween($dateColumn, $this->formatQueryDateBetween([$startingDate, $endingDate]))
398+
->groupBy(DB::raw($expression))
399+
->orderBy('date_result')
400+
->get();
401401

402402
$possibleDateKeys = array_keys($possibleDateResults);
403403

@@ -410,7 +410,7 @@ protected function aggregate(
410410
$request->twelveHourTime === 'true'
411411
) => round($result->aggregate ?? 0, $this->roundingPrecision, $this->roundingMode),
412412
])->reject(static fn ($value, $key) => ! \in_array($key, $possibleDateKeys))
413-
->all()
413+
->all()
414414
);
415415

416416
return $this->result(Arr::last($results))->trend(

src/Nova.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
use Closure;
99
use Illuminate\Console\Command;
1010
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
11-
use Illuminate\Http\Client\Response as ClientResponse;
1211
use Illuminate\Http\Request;
1312
use Illuminate\Support\Collection;
1413
use Illuminate\Support\Facades\Auth;
1514
use Illuminate\Support\Facades\Blade;
16-
use Illuminate\Support\Facades\Cache;
1715
use Illuminate\Support\Facades\File;
1816
use Illuminate\Support\Facades\Gate;
1917
use Illuminate\Support\Facades\Hash;
20-
use Illuminate\Support\Facades\Http;
2118
use Illuminate\Support\Str;
2219
use Illuminate\Validation\Rules\Password;
2320
use Laravel\Nova\Actions\ActionResource;

src/PerformsQueries.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ protected static function applySearch(Builder $query, string $search): Builder
5757

5858
/** @phpstan-ignore nullCoalesce.expr */
5959
$searchColumns = collect(static::searchableColumns() ?? [])
60-
->transform(static function ($column) use ($modelKeyName) {
61-
if ($column === $modelKeyName) {
62-
return new PrimaryKey($column, static::maxPrimaryKeySize());
63-
}
60+
->transform(static function ($column) use ($modelKeyName) {
61+
if ($column === $modelKeyName) {
62+
return new PrimaryKey($column, static::maxPrimaryKeySize());
63+
}
6464

65-
return $column;
66-
})->all();
65+
return $column;
66+
})->all();
6767

6868
return static::initializeSearch($query, $search, $searchColumns);
6969
}

0 commit comments

Comments
 (0)