Skip to content

Commit 8da4d45

Browse files
committed
Apply fixes from StyleCI
1 parent 8f2a18c commit 8da4d45

30 files changed

+98
-102
lines changed

src/Actions/ActionEvent.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public function target()
6767
};
6868

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

7878
/**
@@ -346,9 +346,9 @@ public static function prune(Collection $models, int $limit = 25): void
346346
->whereNotIn('id', static function ($query) use ($model, $limit) {
347347
$query->select('id')->fromSub(
348348
static::select('id')->orderBy('id', 'desc')
349-
->where('actionable_id', $model['actionable_id'])
350-
->where('actionable_type', $model['actionable_type'])
351-
->limit($limit)->toBase(),
349+
->where('actionable_id', $model['actionable_id'])
350+
->where('actionable_type', $model['actionable_type'])
351+
->limit($limit)->toBase(),
352352
'action_events_temp'
353353
);
354354
})->delete();
@@ -361,7 +361,7 @@ public static function prune(Collection $models, int $limit = 25): void
361361
public static function markBatchAsRunning(string $batchId): int
362362
{
363363
return static::where('batch_id', $batchId)
364-
->whereNotIn('status', ['finished', 'failed'])->update([
364+
->whereNotIn('status', ['finished', 'failed'])->update([
365365
'status' => 'running',
366366
]);
367367
}
@@ -372,7 +372,7 @@ public static function markBatchAsRunning(string $batchId): int
372372
public static function markBatchAsFinished(string $batchId): int
373373
{
374374
return static::where('batch_id', $batchId)
375-
->whereNotIn('status', ['finished', 'failed'])->update([
375+
->whereNotIn('status', ['finished', 'failed'])->update([
376376
'status' => 'finished',
377377
]);
378378
}
@@ -395,7 +395,7 @@ public static function markAsFinished(string $batchId, $model): int
395395
public static function markBatchAsFailed(string $batchId, Throwable|string|null $e = null): int
396396
{
397397
return static::where('batch_id', $batchId)
398-
->whereNotIn('status', ['finished', 'failed'])->update([
398+
->whereNotIn('status', ['finished', 'failed'])->update([
399399
'status' => 'failed',
400400
'exception' => $e ? (string) $e : '',
401401
]);
@@ -419,9 +419,9 @@ public static function markAsFailed(string $batchId, $model, Throwable|string|nu
419419
public static function updateStatus(string $batchId, $model, string $status, Throwable|string|null $e = null): int
420420
{
421421
return static::where('batch_id', $batchId)
422-
->where('model_type', $model->getMorphClass())
423-
->where('model_id', $model->getKey())
424-
->update(['status' => $status, 'exception' => (string) $e]);
422+
->where('model_type', $model->getMorphClass())
423+
->where('model_id', $model->getKey())
424+
->update(['status' => $status, 'exception' => (string) $e]);
425425
}
426426

427427
/**

src/Actions/CallQueuedAction.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function handle()
5858
}
5959

6060
return $action->withActionBatchId($this->actionBatchId)
61-
->{$this->method}($this->fields, $this->models);
61+
->{$this->method}($this->fields, $this->models);
6262
});
6363
}
6464

src/Auth/Actions/LoginViewResponse.php

+1
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

-1
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

+2-2
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

+5-5
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ public function __construct($name, ?string $attribute = null, ?string $resource
120120

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

126126
return optional($parent->{$this->attribute})->exists === true;
127127
}
128128

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

135135
/**

src/Fields/ID.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public static function forResource(Resource $resource): ?static
6565
/** @phpstan-ignore argument.templateType */
6666
$field = transform(
6767
$resource->availableFieldsOnIndexOrDetail(app(NovaRequest::class))
68-
->whereInstanceOf(self::class)
69-
->first(),
68+
->whereInstanceOf(self::class)
69+
->first(),
7070
static fn ($field) => tap($field)->resolve($model),
7171
static fn () => ! \is_null($model) && $model->exists ? static::forModel($model) : null,
7272
);

src/Fields/MorphTo.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ protected function filterableAttribute(NovaRequest $request)
541541
protected function defaultFilterableCallback()
542542
{
543543
$morphToTypes = collect($this->morphToTypes)
544-
->pluck('type')
545-
->mapWithKeys(static fn ($type) => [$type => $type::newModel()->getMorphClass()])
546-
->all();
544+
->pluck('type')
545+
->mapWithKeys(static fn ($type) => [$type => $type::newModel()->getMorphClass()])
546+
->all();
547547

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

src/Fields/MorphToMany.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ public function singularLabel(Stringable|string $singularLabel)
230230
public function asPanel(): Panel
231231
{
232232
return Panel::make($this->name, [$this])
233-
->withMeta([
234-
'prefixComponent' => true,
235-
])->withComponent('relationship-panel');
233+
->withMeta([
234+
'prefixComponent' => true,
235+
])->withComponent('relationship-panel');
236236
}
237237

238238
/**

src/Fields/Number.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ public function jsonSerialize(): array
145145
'max' => $this->max,
146146
'step' => $this->step,
147147
])->reject(static fn ($value) => \is_null($value) || (empty($value) && $value !== 0))
148-
->all());
148+
->all());
149149
}
150150
}

src/Fields/Select.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function displayUsingLabels()
6666
}
6767

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

7373
return $this;

src/Http/Controllers/AttachableController.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class AttachableController extends Controller
1414
public function __invoke(NovaRequest $request): array
1515
{
1616
$field = $request->newResource()
17-
->availableFields($request)
18-
->filterForManyToManyRelations()
19-
->filter(static function ($field) use ($request) {
20-
return $field->resourceName === $request->field && // @phpstan-ignore property.notFound
21-
$field->component === $request->component &&
22-
$field->attribute === $request->viaRelationship;
23-
})->first();
17+
->availableFields($request)
18+
->filterForManyToManyRelations()
19+
->filter(static function ($field) use ($request) {
20+
return $field->resourceName === $request->field && // @phpstan-ignore property.notFound
21+
$field->component === $request->component &&
22+
$field->attribute === $request->viaRelationship;
23+
})->first();
2424

2525
abort_if(\is_null($field), 404);
2626

@@ -92,8 +92,8 @@ protected function getAttachableQueryResolver(NovaRequest $request, PivotableFie
9292
$relation = $relatedModel->{$field->manyToManyRelationship}();
9393

9494
return $relation->applyDefaultPivotQuery($query)
95-
->select($relation->getRelatedPivotKeyName())
96-
->whereColumn($relation->getQualifiedRelatedKeyName(), $relation->getQualifiedRelatedPivotKeyName());
95+
->select($relation->getRelatedPivotKeyName())
96+
->whereColumn($relation->getQualifiedRelatedKeyName(), $relation->getQualifiedRelatedPivotKeyName());
9797
});
9898
};
9999
}

src/Http/Controllers/CreationPivotFieldController.php

+1-1
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

+1-1
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

-1
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ public function toResources(Collection $models): Collection
114114
$payload['actions'] = collect(
115115
$hasId === true ? array_values($lensResource->actions($this)) : []
116116
)->filter(static fn ($action) => $action->shownOnIndex() || $action->shownOnTableRow())
117-
->filter->authorizedToSee($this)
118-
->filter->authorizedToRun($this, $model)
119-
->values();
117+
->filter->authorizedToSee($this)
118+
->filter->authorizedToRun($this, $model)
119+
->values();
120120

121121
return $payload;
122122
});

src/Jobs/DeletesFields.php

+5-5
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public static function resource(Resource|string $resourceClass): static
4242
'title' => $resourceClass->title(),
4343
])
4444
)->path('/resources/'.$resourceClass::uriKey().'/'.$resourceClass->getKey())
45-
->canSee(static fn ($request) => $resourceClass->authorizedToView($request));
45+
->canSee(static fn ($request) => $resourceClass->authorizedToView($request));
4646
}
4747

4848
return static::make(
4949
Nova::__($resourceClass::label())
5050
)->path('/resources/'.$resourceClass::uriKey())
51-
->canSee(static fn ($request) => $resourceClass::availableForNavigation($request) && $resourceClass::authorizedToViewAny($request));
51+
->canSee(static fn ($request) => $resourceClass::availableForNavigation($request) && $resourceClass::authorizedToViewAny($request));
5252
}
5353

5454
/**

src/Menu/Menu.php

+3-3
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

+2-2
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

+7-7
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

-3
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

+6-6
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)