Skip to content

Commit 317b4e9

Browse files
fix(Bulk Update): Only Validate Data for Current Item in Loop (#612)
* fix(Bulk Update): Only Validate Data for Current Item in Loop * Fix styling * Run pint * Fix styling --------- Co-authored-by: arthurkirkosa <[email protected]>
1 parent ab53475 commit 317b4e9

26 files changed

+52
-52
lines changed

src/Commands/PublishAuthCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function checkDirectory(string $path): self
6868

6969
protected function copyDirectory(string $path, string $stubDirectory, string $format, ?array $actions = []): self
7070
{
71-
$filesystem = new Filesystem();
71+
$filesystem = new Filesystem;
7272

7373
collect($filesystem->allFiles(__DIR__.$stubDirectory))
7474
->filter(function (SplFileInfo $file) use ($actions) {

src/Fields/Concerns/Attachable.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function authorizeToAttach(RestifyRequest $request)
8989
);
9090

9191
if (! $this->authorizedToAttach($request, $pivot)) {
92-
throw new AuthorizationException();
92+
throw new AuthorizationException;
9393
}
9494
});
9595

@@ -106,7 +106,7 @@ public function authorizeToSync(RestifyRequest $request)
106106
);
107107

108108
if (! $this->authorizedToSync($request, $pivot)) {
109-
throw new AuthorizationException();
109+
throw new AuthorizationException;
110110
}
111111
});
112112

@@ -123,7 +123,7 @@ public function authorizedToDetach(RestifyRequest $request, Pivot $pivot): bool
123123
public function authorizeToDetach(RestifyRequest $request, Pivot $pivot)
124124
{
125125
if (! $this->authorizedToDetach($request, $pivot)) {
126-
throw new AuthorizationException();
126+
throw new AuthorizationException;
127127
}
128128

129129
return $this;
@@ -156,8 +156,8 @@ public function initializePivot(RestifyRequest $request, $relationship, $related
156156

157157
if ($relationship->withTimestamps) {
158158
$pivot->forceFill([
159-
$relationship->createdAt() => new DateTime(),
160-
$relationship->updatedAt() => new DateTime(),
159+
$relationship->createdAt() => new DateTime,
160+
$relationship->updatedAt() => new DateTime,
161161
]);
162162
}
163163

src/Http/Controllers/Auth/ForgotPasswordController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __invoke(Request $request)
2929
$request->input('url') ?? config('restify.auth.password_reset_url')
3030
);
3131

32-
(new AnonymousNotifiable())->route('mail', $user->email)->notify(new ForgotPasswordNotification($url));
32+
(new AnonymousNotifiable)->route('mail', $user->email)->notify(new ForgotPasswordNotification($url));
3333

3434
return ok(__('Reset password link sent to your email.'));
3535
}

src/Http/Controllers/RepositoryUpdateBulkController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __invoke(RepositoryUpdateBulkRequest $request)
2121
$repository = $request->repositoryWith($model);
2222

2323
return $repository
24-
->allowToUpdateBulk($request)
24+
->allowToUpdateBulk($request, $item)
2525
->updateBulk(
2626
$request,
2727
$id,

src/Http/Controllers/RestResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ public function __call($func, $args)
252252
public function respond($response = null): JsonResponse
253253
{
254254
if (! func_num_args()) {
255-
$response = new \stdClass();
256-
$response->data = new \stdClass();
255+
$response = new \stdClass;
256+
$response->data = new \stdClass;
257257

258258
foreach (static::$RESPONSE_DEFAULT_ATTRIBUTES as $property) {
259259
if (isset($this->{$property})) {
@@ -537,7 +537,7 @@ public function model(Model $model): self
537537

538538
public static function created()
539539
{
540-
return (new self())->code(201);
540+
return (new self)->code(201);
541541
}
542542

543543
public static function index(AbstractPaginator|Paginator $paginator, array $meta = []): JsonResponse

src/LaravelRestifyServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function packageRegistered(): void
6262

6363
// Register the main class to use with the facade
6464
$this->app->singleton('laravel-restify', function () {
65-
return new Restify();
65+
return new Restify;
6666
});
6767
}
6868

src/Repositories/ValidatingTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static function validatorForUpdateBulk(RestifyRequest $request, $resource
171171
})->toArray();
172172

173173
return Validator::make(
174-
$plainPayload ?? $request->all(),
174+
[$plainPayload] ?? $request->all(),
175175
$on->getUpdatingBulkRules($request),
176176
$messages
177177
)->after(function ($validator) use ($request) {

src/Restify.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function repositories(array $repositories)
132132
(new BootRepository($repository))->boot();
133133
});
134134

135-
return new static();
135+
return new static;
136136
}
137137

138138
/**
@@ -149,7 +149,7 @@ public static function repositoriesFrom(string $directory, string $namespace): v
149149
return;
150150
}
151151

152-
foreach ((new Finder())->in($directory)->files() as $repository) {
152+
foreach ((new Finder)->in($directory)->files() as $repository) {
153153
$repository = $namespace.str_replace(
154154
['/', '.php'],
155155
['\\', ''],

src/RestifyApplicationServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function routes(): void
133133
protected function singleton(): void
134134
{
135135
if (! App::runningUnitTests()) {
136-
$this->app->singletonIf(RelatedDto::class, fn ($app) => new RelatedDto());
136+
$this->app->singletonIf(RelatedDto::class, fn ($app) => new RelatedDto);
137137
}
138138
}
139139
}

src/Services/Search/RepositorySearchService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,6 @@ protected function applyFilters(RestifyRequest $request, Repository $repository,
219219

220220
public static function make(): static
221221
{
222-
return new static();
222+
return new static;
223223
}
224224
}

0 commit comments

Comments
 (0)