Skip to content

Fix phpstan errors #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/Http/Controllers/Admin/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public function __invoke(Request $request): JsonResponse

$file = $request->file('upload');

if (is_array($file)) {
$file = $file[0];
}

if (! $file instanceof UploadedFile) {
return response()->json(['error' => 'Invalid upload'], 400);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Admin/AuditTrails.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function sortBy(string $field): void
}

/**
* @return LengthAwarePaginator<AuditTrail>
* @return LengthAwarePaginator<int, AuditTrail>
*/
public function userLogs(): LengthAwarePaginator
{
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Admin/Roles/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function sortBy(string $field): void
}

/**
* @return LengthAwarePaginator<Role>
* @return LengthAwarePaginator<int, Role>
*/
public function roles(): LengthAwarePaginator
{
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Admin/Users/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function sortBy(string $field): void
}

/**
* @return LengthAwarePaginator<User>
* @return LengthAwarePaginator<int, User>
*/
public function users(): LengthAwarePaginator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<div class="card">
<x-form wire:submit="update" method="put">

<x-alert>
<p class="text-white">{{ __('New password must be at least 8 characters in length') }}<br>
<x-alert class="text-white">
<div>{{ __('New password must be at least 8 characters in length') }}<br>
{{ __('at least one lowercase letter') }}<br>
{{ __('at least one uppercase letter') }}<br>
{{ __('at least one digit') }}</p>
{{ __('at least one digit') }}</div>
</x-alert>

<x-form.input wire:model="newPassword" type="password" :label="__('New Password')" name='newPassword' />
Expand Down
19 changes: 0 additions & 19 deletions tests/Feature/App/Http/Controllers/Admin/UploadControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@
Storage::disk('images')->assertExists($path);
});

test('handles valid upload when file is sent as an array', function () {
$file = UploadedFile::fake()->image('photo.jpg');

$mockRequest = Mockery::mock(Request::class);
$mockRequest->shouldReceive('validate')->andReturn(['upload' => [$file]]);
$mockRequest->shouldReceive('hasFile')->once()->with('upload')->andReturn(true);
$mockRequest->shouldReceive('file')->once()->with('upload')->andReturn([$file]);

$controller = new UploadController;

$response = $controller($mockRequest);

expect($response->getStatusCode())->toBe(200);
expect($response->getData(true))->toHaveKey('url');

$path = str_replace('/images/', '', $response->getData(true)['url']);
Storage::disk('images')->assertExists($path);
});

test('fails when no file is uploaded', function () {
postJson(route('image-upload'), [])->assertStatus(422);
});
Expand Down