diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79157b074..b241ba2ef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: true matrix: - stack: [blade, livewire, react, vue, api] + stack: [blade, livewire, livewire-functional, react, vue, api] laravel: [10] args: ["", --pest] include: diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index d71116c8e..bd6f8f63b 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -26,7 +26,7 @@ class InstallCommand extends Command implements PromptsForMissingInput * * @var string */ - protected $signature = 'breeze:install {stack : The development stack that should be installed (blade,livewire,react,vue,api)} + protected $signature = 'breeze:install {stack : The development stack that should be installed (blade,livewire,livewire-functional,react,vue,api)} {--dark : Indicate that dark mode support should be installed} {--pest : Indicate that Pest should be installed} {--ssr : Indicates if Inertia SSR support should be installed} @@ -57,9 +57,11 @@ public function handle() return $this->installBladeStack(); } elseif ($this->argument('stack') === 'livewire') { return $this->installLivewireStack(); + } elseif ($this->argument('stack') === 'livewire-functional') { + return $this->installLivewireStack(true); } - $this->components->error('Invalid stack. Supported stacks are [blade], [livewire], [react], [vue], and [api].'); + $this->components->error('Invalid stack. Supported stacks are [blade], [livewire], [livewire-functional], [react], [vue], and [api].'); return 1; } @@ -75,7 +77,8 @@ protected function installTests() $stubStack = match ($this->argument('stack')) { 'api' => 'api', - 'livewire' => 'livewire', + 'livewire' => 'livewire-common', + 'livewire-functional' => 'livewire-common', default => 'default', }; @@ -314,7 +317,8 @@ protected function promptForMissingArgumentsUsing() label: 'Which Breeze stack would you like to install?', options: [ 'blade' => 'Blade with Alpine', - 'livewire' => 'Livewire with Alpine', + 'livewire' => 'Livewire (Volt Class API) with Alpine', + 'livewire-functional' => 'Livewire (Volt Functional API) with Alpine', 'react' => 'React with Inertia', 'vue' => 'Vue with Inertia', 'api' => 'API only', @@ -343,7 +347,7 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp 'typescript' => 'TypeScript (experimental)', ] ))->each(fn ($option) => $input->setOption($option, true)); - } elseif (in_array($stack, ['blade', 'livewire'])) { + } elseif (in_array($stack, ['blade', 'livewire', 'livewire-functional'])) { $input->setOption('dark', confirm( label: 'Would you like dark mode support?', default: false diff --git a/src/Console/InstallsLivewireStack.php b/src/Console/InstallsLivewireStack.php index 525b307e0..19114c89e 100644 --- a/src/Console/InstallsLivewireStack.php +++ b/src/Console/InstallsLivewireStack.php @@ -13,7 +13,7 @@ trait InstallsLivewireStack * * @return int|null */ - protected function installLivewireStack() + protected function installLivewireStack($functional = false) { // NPM Packages... $this->updateNodePackages(function ($packages) { @@ -44,16 +44,22 @@ protected function installLivewireStack() // Views... (new Filesystem)->ensureDirectoryExists(resource_path('views')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire/resources/views', resource_path('views')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/resources/views', resource_path('views')); + + // Livewire Components... + (new Filesystem)->ensureDirectoryExists(resource_path('views/livewire')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/' + .($functional ? 'livewire-functional' : 'livewire') + .'/resources/views/livewire', resource_path('views/livewire')); // Views Components... (new Filesystem)->ensureDirectoryExists(resource_path('views/components')); (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/resources/views/components', resource_path('views/components')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire/resources/views/components', resource_path('views/components')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/resources/views/components', resource_path('views/components')); // Views Layouts... (new Filesystem)->ensureDirectoryExists(resource_path('views/layouts')); - (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire/resources/views/layouts', resource_path('views/layouts')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/resources/views/layouts', resource_path('views/layouts')); // Components... (new Filesystem)->ensureDirectoryExists(app_path('View/Components')); @@ -74,8 +80,8 @@ protected function installLivewireStack() } // Routes... - copy(__DIR__.'/../../stubs/livewire/routes/web.php', base_path('routes/web.php')); - copy(__DIR__.'/../../stubs/livewire/routes/auth.php', base_path('routes/auth.php')); + copy(__DIR__.'/../../stubs/livewire-common/routes/web.php', base_path('routes/web.php')); + copy(__DIR__.'/../../stubs/livewire-common/routes/auth.php', base_path('routes/auth.php')); // "Dashboard" Route... $this->replaceInFile('/home', '/dashboard', app_path('Providers/RouteServiceProvider.php')); diff --git a/stubs/livewire/pest-tests/Feature/Auth/AuthenticationTest.php b/stubs/livewire-common/pest-tests/Feature/Auth/AuthenticationTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/Auth/AuthenticationTest.php rename to stubs/livewire-common/pest-tests/Feature/Auth/AuthenticationTest.php diff --git a/stubs/livewire/pest-tests/Feature/Auth/EmailVerificationTest.php b/stubs/livewire-common/pest-tests/Feature/Auth/EmailVerificationTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/Auth/EmailVerificationTest.php rename to stubs/livewire-common/pest-tests/Feature/Auth/EmailVerificationTest.php diff --git a/stubs/livewire/pest-tests/Feature/Auth/PasswordConfirmationTest.php b/stubs/livewire-common/pest-tests/Feature/Auth/PasswordConfirmationTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/Auth/PasswordConfirmationTest.php rename to stubs/livewire-common/pest-tests/Feature/Auth/PasswordConfirmationTest.php diff --git a/stubs/livewire/pest-tests/Feature/Auth/PasswordResetTest.php b/stubs/livewire-common/pest-tests/Feature/Auth/PasswordResetTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/Auth/PasswordResetTest.php rename to stubs/livewire-common/pest-tests/Feature/Auth/PasswordResetTest.php diff --git a/stubs/livewire/pest-tests/Feature/Auth/PasswordUpdateTest.php b/stubs/livewire-common/pest-tests/Feature/Auth/PasswordUpdateTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/Auth/PasswordUpdateTest.php rename to stubs/livewire-common/pest-tests/Feature/Auth/PasswordUpdateTest.php diff --git a/stubs/livewire/pest-tests/Feature/Auth/RegistrationTest.php b/stubs/livewire-common/pest-tests/Feature/Auth/RegistrationTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/Auth/RegistrationTest.php rename to stubs/livewire-common/pest-tests/Feature/Auth/RegistrationTest.php diff --git a/stubs/livewire/pest-tests/Feature/ExampleTest.php b/stubs/livewire-common/pest-tests/Feature/ExampleTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/ExampleTest.php rename to stubs/livewire-common/pest-tests/Feature/ExampleTest.php diff --git a/stubs/livewire/pest-tests/Feature/ProfileTest.php b/stubs/livewire-common/pest-tests/Feature/ProfileTest.php similarity index 100% rename from stubs/livewire/pest-tests/Feature/ProfileTest.php rename to stubs/livewire-common/pest-tests/Feature/ProfileTest.php diff --git a/stubs/livewire/pest-tests/Pest.php b/stubs/livewire-common/pest-tests/Pest.php similarity index 100% rename from stubs/livewire/pest-tests/Pest.php rename to stubs/livewire-common/pest-tests/Pest.php diff --git a/stubs/livewire/pest-tests/Unit/ExampleTest.php b/stubs/livewire-common/pest-tests/Unit/ExampleTest.php similarity index 100% rename from stubs/livewire/pest-tests/Unit/ExampleTest.php rename to stubs/livewire-common/pest-tests/Unit/ExampleTest.php diff --git a/stubs/livewire/resources/views/components/action-message.blade.php b/stubs/livewire-common/resources/views/components/action-message.blade.php similarity index 100% rename from stubs/livewire/resources/views/components/action-message.blade.php rename to stubs/livewire-common/resources/views/components/action-message.blade.php diff --git a/stubs/livewire/resources/views/dashboard.blade.php b/stubs/livewire-common/resources/views/dashboard.blade.php similarity index 100% rename from stubs/livewire/resources/views/dashboard.blade.php rename to stubs/livewire-common/resources/views/dashboard.blade.php diff --git a/stubs/livewire/resources/views/layouts/app.blade.php b/stubs/livewire-common/resources/views/layouts/app.blade.php similarity index 100% rename from stubs/livewire/resources/views/layouts/app.blade.php rename to stubs/livewire-common/resources/views/layouts/app.blade.php diff --git a/stubs/livewire/resources/views/layouts/guest.blade.php b/stubs/livewire-common/resources/views/layouts/guest.blade.php similarity index 100% rename from stubs/livewire/resources/views/layouts/guest.blade.php rename to stubs/livewire-common/resources/views/layouts/guest.blade.php diff --git a/stubs/livewire/resources/views/profile.blade.php b/stubs/livewire-common/resources/views/profile.blade.php similarity index 100% rename from stubs/livewire/resources/views/profile.blade.php rename to stubs/livewire-common/resources/views/profile.blade.php diff --git a/stubs/livewire/resources/views/welcome.blade.php b/stubs/livewire-common/resources/views/welcome.blade.php similarity index 100% rename from stubs/livewire/resources/views/welcome.blade.php rename to stubs/livewire-common/resources/views/welcome.blade.php diff --git a/stubs/livewire/routes/auth.php b/stubs/livewire-common/routes/auth.php similarity index 100% rename from stubs/livewire/routes/auth.php rename to stubs/livewire-common/routes/auth.php diff --git a/stubs/livewire/routes/web.php b/stubs/livewire-common/routes/web.php similarity index 100% rename from stubs/livewire/routes/web.php rename to stubs/livewire-common/routes/web.php diff --git a/stubs/livewire/tests/Feature/Auth/AuthenticationTest.php b/stubs/livewire-common/tests/Feature/Auth/AuthenticationTest.php similarity index 100% rename from stubs/livewire/tests/Feature/Auth/AuthenticationTest.php rename to stubs/livewire-common/tests/Feature/Auth/AuthenticationTest.php diff --git a/stubs/livewire/tests/Feature/Auth/EmailVerificationTest.php b/stubs/livewire-common/tests/Feature/Auth/EmailVerificationTest.php similarity index 100% rename from stubs/livewire/tests/Feature/Auth/EmailVerificationTest.php rename to stubs/livewire-common/tests/Feature/Auth/EmailVerificationTest.php diff --git a/stubs/livewire/tests/Feature/Auth/PasswordConfirmationTest.php b/stubs/livewire-common/tests/Feature/Auth/PasswordConfirmationTest.php similarity index 100% rename from stubs/livewire/tests/Feature/Auth/PasswordConfirmationTest.php rename to stubs/livewire-common/tests/Feature/Auth/PasswordConfirmationTest.php diff --git a/stubs/livewire/tests/Feature/Auth/PasswordResetTest.php b/stubs/livewire-common/tests/Feature/Auth/PasswordResetTest.php similarity index 100% rename from stubs/livewire/tests/Feature/Auth/PasswordResetTest.php rename to stubs/livewire-common/tests/Feature/Auth/PasswordResetTest.php diff --git a/stubs/livewire/tests/Feature/Auth/PasswordUpdateTest.php b/stubs/livewire-common/tests/Feature/Auth/PasswordUpdateTest.php similarity index 100% rename from stubs/livewire/tests/Feature/Auth/PasswordUpdateTest.php rename to stubs/livewire-common/tests/Feature/Auth/PasswordUpdateTest.php diff --git a/stubs/livewire/tests/Feature/Auth/RegistrationTest.php b/stubs/livewire-common/tests/Feature/Auth/RegistrationTest.php similarity index 100% rename from stubs/livewire/tests/Feature/Auth/RegistrationTest.php rename to stubs/livewire-common/tests/Feature/Auth/RegistrationTest.php diff --git a/stubs/livewire/tests/Feature/ProfileTest.php b/stubs/livewire-common/tests/Feature/ProfileTest.php similarity index 100% rename from stubs/livewire/tests/Feature/ProfileTest.php rename to stubs/livewire-common/tests/Feature/ProfileTest.php diff --git a/stubs/livewire-functional/resources/views/livewire/layout/navigation.blade.php b/stubs/livewire-functional/resources/views/livewire/layout/navigation.blade.php new file mode 100644 index 000000000..747e58285 --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/layout/navigation.blade.php @@ -0,0 +1,105 @@ +guard('web')->logout(); + + session()->invalidate(); + session()->regenerateToken(); + + $this->redirect('/', navigate: true); +}; + +?> + + diff --git a/stubs/livewire-functional/resources/views/livewire/pages/auth/confirm-password.blade.php b/stubs/livewire-functional/resources/views/livewire/pages/auth/confirm-password.blade.php new file mode 100644 index 000000000..2f4c0015f --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/pages/auth/confirm-password.blade.php @@ -0,0 +1,64 @@ + '']); + +rules(['password' => ['required', 'string']]); + +$confirmPassword = function () { + $this->validate(); + + if (! auth()->guard('web')->validate([ + 'email' => auth()->user()->email, + 'password' => $this->password, + ])) { + throw ValidationException::withMessages([ + 'password' => __('auth.password'), + ]); + } + + session(['auth.password_confirmed_at' => time()]); + + $this->redirect( + session('url.intended', RouteServiceProvider::HOME), + navigate: true + ); +}; + +?> + +
+
+ {{ __('This is a secure area of the application. Please confirm your password before continuing.') }} +
+ +
+ +
+ + + + + +
+ +
+ + {{ __('Confirm') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/pages/auth/forgot-password.blade.php b/stubs/livewire-functional/resources/views/livewire/pages/auth/forgot-password.blade.php new file mode 100644 index 000000000..9e3822748 --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/pages/auth/forgot-password.blade.php @@ -0,0 +1,60 @@ + '']); + +rules(['email' => ['required', 'string', 'email']]); + +$sendPasswordResetLink = function () { + $this->validate(); + + // We will send the password reset link to this user. Once we have attempted + // to send the link, we will examine the response then see the message we + // need to show to the user. Finally, we'll send out a proper response. + $status = Password::sendResetLink( + $this->only('email') + ); + + if ($status != Password::RESET_LINK_SENT) { + $this->addError('email', __($status)); + + return; + } + + $this->reset('email'); + + session()->flash('status', __($status)); +}; + +?> + +
+
+ {{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }} +
+ + + + +
+ +
+ + + +
+ +
+ + {{ __('Email Password Reset Link') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/pages/auth/login.blade.php b/stubs/livewire-functional/resources/views/livewire/pages/auth/login.blade.php new file mode 100644 index 000000000..108de7f4d --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/pages/auth/login.blade.php @@ -0,0 +1,105 @@ + '', 'password' => '', 'remember' => false]); + +rules([ + 'email' => ['required', 'string', 'email'], + 'password' => ['required', 'string'], + 'remember' => ['boolean'], +]); + +$login = function () { + $this->validate(); + + $throttleKey = Str::transliterate(Str::lower($this->email).'|'.request()->ip()); + + if (RateLimiter::tooManyAttempts($throttleKey, 5)) { + event(new Lockout(request())); + + $seconds = RateLimiter::availableIn($throttleKey); + + throw ValidationException::withMessages([ + 'email' => trans('auth.throttle', [ + 'seconds' => $seconds, + 'minutes' => ceil($seconds / 60), + ]), + ]); + } + + if (! auth()->attempt($this->only(['email', 'password'], $this->remember))) { + RateLimiter::hit($throttleKey); + + throw ValidationException::withMessages([ + 'email' => trans('auth.failed'), + ]); + } + + RateLimiter::clear($throttleKey); + + session()->regenerate(); + + $this->redirect( + session('url.intended', RouteServiceProvider::HOME), + navigate: true + ); +}; + +?> + +
+ + + +
+ +
+ + + +
+ + +
+ + + + + +
+ + +
+ +
+ +
+ @if (Route::has('password.request')) + + {{ __('Forgot your password?') }} + + @endif + + + {{ __('Log in') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/pages/auth/register.blade.php b/stubs/livewire-functional/resources/views/livewire/pages/auth/register.blade.php new file mode 100644 index 000000000..66c8b2f7e --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/pages/auth/register.blade.php @@ -0,0 +1,90 @@ + '', + 'email' => '', + 'password' => '', + 'password_confirmation' => '' +]); + +rules([ + 'name' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class], + 'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()], +]); + +$register = function () { + $validated = $this->validate(); + + $validated['password'] = Hash::make($validated['password']); + + event(new Registered($user = User::create($validated))); + + auth()->login($user); + + $this->redirect(RouteServiceProvider::HOME, navigate: true); +}; + +?> + +
+
+ +
+ + + +
+ + +
+ + + +
+ + +
+ + + + + +
+ + +
+ + + + + +
+ +
+ + {{ __('Already registered?') }} + + + + {{ __('Register') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/pages/auth/reset-password.blade.php b/stubs/livewire-functional/resources/views/livewire/pages/auth/reset-password.blade.php new file mode 100644 index 000000000..cca45754e --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/pages/auth/reset-password.blade.php @@ -0,0 +1,96 @@ +locked(); + +state([ + 'email' => fn () => request()->string('email')->value(), + 'password' => '', + 'password_confirmation' => '' +]); + +rules([ + 'token' => ['required'], + 'email' => ['required', 'string', 'email'], + 'password' => ['required', 'string', 'confirmed', Rules\Password::defaults()], +]); + +$resetPassword = function () { + $this->validate(); + + // Here we will attempt to reset the user's password. If it is successful we + // will update the password on an actual user model and persist it to the + // database. Otherwise we will parse the error and return the response. + $status = Password::reset( + $this->only('email', 'password', 'password_confirmation', 'token'), + function ($user) { + $user->forceFill([ + 'password' => Hash::make($this->password), + 'remember_token' => Str::random(60), + ])->save(); + + event(new PasswordReset($user)); + } + ); + + // If the password was successfully reset, we will redirect the user back to + // the application's home authenticated view. If there is an error we can + // redirect them back to where they came from with their error message. + if ($status != Password::PASSWORD_RESET) { + $this->addError('email', __($status)); + + return; + } + + session()->flash('status', __($status)); + + $this->redirectRoute('login', navigate: true); +}; + +?> + +
+
+ +
+ + + +
+ + +
+ + + +
+ + +
+ + + + + +
+ +
+ + {{ __('Reset Password') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/pages/auth/verify-email.blade.php b/stubs/livewire-functional/resources/views/livewire/pages/auth/verify-email.blade.php new file mode 100644 index 000000000..376397cbc --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/pages/auth/verify-email.blade.php @@ -0,0 +1,55 @@ +user()->hasVerifiedEmail()) { + $this->redirect( + session('url.intended', RouteServiceProvider::HOME), + navigate: true + ); + + return; + } + + auth()->user()->sendEmailVerificationNotification(); + + session()->flash('status', 'verification-link-sent'); +}; + +$logout = function () { + auth()->guard('web')->logout(); + + session()->invalidate(); + session()->regenerateToken(); + + $this->redirect('/', navigate: true); +}; + +?> + +
+
+ {{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }} +
+ + @if (session('status') == 'verification-link-sent') +
+ {{ __('A new verification link has been sent to the email address you provided during registration.') }} +
+ @endif + +
+ + {{ __('Resend Verification Email') }} + + + +
+
diff --git a/stubs/livewire-functional/resources/views/livewire/profile/delete-user-form.blade.php b/stubs/livewire-functional/resources/views/livewire/profile/delete-user-form.blade.php new file mode 100644 index 000000000..154a96088 --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/profile/delete-user-form.blade.php @@ -0,0 +1,76 @@ + '']); + +rules(['password' => ['required', 'string', 'current_password']]); + +$deleteUser = function () { + $this->validate(); + + tap(auth()->user(), fn () => auth()->logout())->delete(); + + session()->invalidate(); + session()->regenerateToken(); + + $this->redirect('/', navigate: true); +}; + +?> + +
+
+

+ {{ __('Delete Account') }} +

+ +

+ {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.') }} +

+
+ + {{ __('Delete Account') }} + + +
+ +

+ {{ __('Are you sure you want to delete your account?') }} +

+ +

+ {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.') }} +

+ +
+ + + + + +
+ +
+ + {{ __('Cancel') }} + + + + {{ __('Delete Account') }} + +
+
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/profile/update-password-form.blade.php b/stubs/livewire-functional/resources/views/livewire/profile/update-password-form.blade.php new file mode 100644 index 000000000..a36ccd008 --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/profile/update-password-form.blade.php @@ -0,0 +1,79 @@ + '', + 'password' => '', + 'password_confirmation' => '' +]); + +rules([ + 'current_password' => ['required', 'string', 'current_password'], + 'password' => ['required', 'string', Password::defaults(), 'confirmed'], +]); + +$updatePassword = function () { + try { + $validated = $this->validate(); + } catch (ValidationException $e) { + $this->reset('current_password', 'password', 'password_confirmation'); + + throw $e; + } + + auth()->user()->update([ + 'password' => Hash::make($validated['password']), + ]); + + $this->reset('current_password', 'password', 'password_confirmation'); + + $this->dispatch('password-updated'); +}; + +?> + +
+
+

+ {{ __('Update Password') }} +

+ +

+ {{ __('Ensure your account is using a long, random password to stay secure.') }} +

+
+ +
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ {{ __('Save') }} + + + {{ __('Saved.') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/profile/update-profile-information-form.blade.php b/stubs/livewire-functional/resources/views/livewire/profile/update-profile-information-form.blade.php new file mode 100644 index 000000000..0b59e7f20 --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/profile/update-profile-information-form.blade.php @@ -0,0 +1,102 @@ + fn () => auth()->user()->name, + 'email' => fn () => auth()->user()->email +]); + +$updateProfileInformation = function () { + $user = auth()->user(); + + $validated = $this->validate([ + 'name' => ['required', 'string', 'max:255'], + 'email' => ['required', 'email', 'max:255', Rule::unique(User::class)->ignore($user->id)], + ]); + + $user->fill($validated); + + if ($user->isDirty('email')) { + $user->email_verified_at = null; + } + + $user->save(); + + $this->dispatch('profile-updated', name: $user->name); +}; + +$sendVerification = function () { + $user = auth()->user(); + + if ($user->hasVerifiedEmail()) { + $path = session('url.intended', RouteServiceProvider::HOME); + + $this->redirect($path); + + return; + } + + $user->sendEmailVerificationNotification(); + + session()->flash('status', 'verification-link-sent'); +}; + +?> + +
+
+

+ {{ __('Profile Information') }} +

+ +

+ {{ __("Update your account's profile information and email address.") }} +

+
+ +
+
+ + + +
+ +
+ + + + + @if (auth()->user() instanceof MustVerifyEmail && ! auth()->user()->hasVerifiedEmail()) +
+

+ {{ __('Your email address is unverified.') }} + + +

+ + @if (session('status') === 'verification-link-sent') +

+ {{ __('A new verification link has been sent to your email address.') }} +

+ @endif +
+ @endif +
+ +
+ {{ __('Save') }} + + + {{ __('Saved.') }} + +
+
+
diff --git a/stubs/livewire-functional/resources/views/livewire/welcome/navigation.blade.php b/stubs/livewire-functional/resources/views/livewire/welcome/navigation.blade.php new file mode 100644 index 000000000..4ee37bbbe --- /dev/null +++ b/stubs/livewire-functional/resources/views/livewire/welcome/navigation.blade.php @@ -0,0 +1,11 @@ +
+ @auth + Dashboard + @else + Log in + + @if (Route::has('register')) + Register + @endif + @endauth +
diff --git a/stubs/livewire/resources/views/livewire/pages/auth/register.blade.php b/stubs/livewire/resources/views/livewire/pages/auth/register.blade.php index 9397bfdeb..b5d791d53 100644 --- a/stubs/livewire/resources/views/livewire/pages/auth/register.blade.php +++ b/stubs/livewire/resources/views/livewire/pages/auth/register.blade.php @@ -11,8 +11,11 @@ new #[Layout('layouts.guest')] class extends Component { public string $name = ''; + public string $email = ''; + public string $password = ''; + public string $password_confirmation = ''; public function register(): void diff --git a/stubs/livewire/resources/views/livewire/pages/auth/reset-password.blade.php b/stubs/livewire/resources/views/livewire/pages/auth/reset-password.blade.php index 236c2345a..e258c4c85 100644 --- a/stubs/livewire/resources/views/livewire/pages/auth/reset-password.blade.php +++ b/stubs/livewire/resources/views/livewire/pages/auth/reset-password.blade.php @@ -13,8 +13,11 @@ { #[Locked] public string $token = ''; + public string $email = ''; + public string $password = ''; + public string $password_confirmation = ''; public function mount(string $token): void diff --git a/stubs/livewire/resources/views/livewire/profile/update-password-form.blade.php b/stubs/livewire/resources/views/livewire/profile/update-password-form.blade.php index d4df3fed2..2f07531ac 100644 --- a/stubs/livewire/resources/views/livewire/profile/update-password-form.blade.php +++ b/stubs/livewire/resources/views/livewire/profile/update-password-form.blade.php @@ -8,7 +8,9 @@ new class extends Component { public string $current_password = ''; + public string $password = ''; + public string $password_confirmation = ''; public function updatePassword(): void diff --git a/stubs/livewire/resources/views/livewire/profile/update-profile-information-form.blade.php b/stubs/livewire/resources/views/livewire/profile/update-profile-information-form.blade.php index 8f2829668..bb2d41ab4 100644 --- a/stubs/livewire/resources/views/livewire/profile/update-profile-information-form.blade.php +++ b/stubs/livewire/resources/views/livewire/profile/update-profile-information-form.blade.php @@ -2,13 +2,13 @@ use App\Models\User; use App\Providers\RouteServiceProvider; -use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Validation\Rule; use Livewire\Volt\Component; new class extends Component { public string $name = ''; + public string $email = ''; public function mount(): void @@ -78,7 +78,7 @@ public function sendVerification(): void - @if (auth()->user() instanceof MustVerifyEmail && ! auth()->user()->hasVerifiedEmail()) + @if (auth()->user() instanceof \Illuminate\Contracts\Auth\MustVerifyEmail && ! auth()->user()->hasVerifiedEmail())

{{ __('Your email address is unverified.') }}