URL Shortener 1.0
A Laravel-based URL shortener application
Chargement...
Recherche...
Aucune correspondance
UpdateUserProfileInformation.php
Aller à la documentation de ce fichier.
1<?php
2
3namespace App\Actions\Fortify;
4
6use Illuminate\Contracts\Auth\MustVerifyEmail;
7use Illuminate\Support\Facades\Validator;
8use Illuminate\Validation\Rule;
9use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
10
11class UpdateUserProfileInformation implements UpdatesUserProfileInformation
12{
18 public function update(User $user, array $input): void
19 {
20 Validator::make($input, [
21 'name' => ['required', 'string', 'max:255'],
22
23 'email' => [
24 'required',
25 'string',
26 'email',
27 'max:255',
28 Rule::unique('users')->ignore($user->id),
29 ],
30 ])->validateWithBag('updateProfileInformation');
31
32 if ($input['email'] !== $user->email &&
33 $user instanceof MustVerifyEmail) {
34 $this->updateVerifiedUser($user, $input);
35 } else {
36 $user->forceFill([
37 'name' => $input['name'],
38 'email' => $input['email'],
39 ])->save();
40 }
41 }
42
48 protected function updateVerifiedUser(User $user, array $input): void
49 {
50 $user->forceFill([
51 'name' => $input['name'],
52 'email' => $input['email'],
53 'email_verified_at' => null,
54 ])->save();
55
56 $user->sendEmailVerificationNotification();
57 }
58}
updateVerifiedUser(User $user, array $input)
Update the given verified user's profile information.
update(User $user, array $input)
Validate and update the given user's profile information.