Files
Sistema-Educativo-Laravel/app/Actions/Fortify/UpdateUserProfileInformation.php
T
fernando 56f4e3b226 Increase file upload validation limits
- EntregaController: max:2048 -> max:20480 (2MB -> 20MB)
- UpdateUserProfileInformation: max:1024 -> max:5120 (1MB -> 5MB)

The server-level limits (nginx client_max_body_size and php.ini) were
already raised in the previous commit; these Laravel validation rules
were the remaining bottleneck blocking uploads over 2MB.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 08:01:13 -06:00

61 lines
1.9 KiB
PHP

<?php
namespace App\Actions\Fortify;
use App\Models\User;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
{
/**
* Validate and update the given user's profile information.
*
* @param array<string, mixed> $input
*/
public function update(User $user, array $input): void
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'apellidoPaterno' => ['nullable', 'string', 'max:255'],
'apellidoMaterno' => ['nullable', 'string', 'max:255'],
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:5120'],
])->validateWithBag('updateProfileInformation');
if (isset($input['photo'])) {
$user->updateProfilePhoto($input['photo']);
}
if ($input['email'] !== $user->email &&
$user instanceof MustVerifyEmail) {
$this->updateVerifiedUser($user, $input);
} else {
$user->forceFill([
'name' => $input['name'],
'apellidoPaterno' => $input['apellidoPaterno'],
'apellidoMaterno' => $input['apellidoMaterno'],
'email' => $input['email'],
])->save();
}
}
/**
* Update the given verified user's profile information.
*
* @param array<string, string> $input
*/
protected function updateVerifiedUser(User $user, array $input): void
{
$user->forceFill([
'name' => $input['name'],
'email' => $input['email'],
'email_verified_at' => null,
])->save();
$user->sendEmailVerificationNotification();
}
}