Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jcc5018's avatar

confusion around lavavel breeze with Volt set up

So as per usual every time some new tech comes out, it changes how things are done and confuses me just when I start to figure out the old ways.

I set up a new project with Breeze and I am assuming volt which created the form below for a login page. Which is fine, but that creates a full page for login. I'd like to also have a login on the home page for non-logged-in users.

I understand that I can call a volt component as usual like livewire:pages.auth.login

But if that page is set up as a full page, how can i modify it to reuse just the login parts elsewhere as a component? Also since I installed filament after breeze, is there going to be a conflict between the logic of the two?

use App\Livewire\Forms\LoginForm;
use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;

new #[Layout('components.layouts.app')] class extends Component {
    public LoginForm $form;

    /**
     * Handle an incoming authentication request.
     */
    public function login(): void
    {
        $this->validate();

        $this->form->authenticate();

        Session::regenerate();

        $this->redirect(
            session('url.intended', RouteServiceProvider::HOME),
            navigate: true
        );
    }
}; ?>

<section class="items-center">
    <h1>Login</h1>
    <div class="container w-6/12">
        <!-- Session Status -->
        <x-auth-session-status class="mb-4" :status="session('status')"/>

        <form wire:submit="login">
            <!-- Email Address -->
            <div>
                <x-input-label for="email" :value="__('Email')"/>
                <x-text-input wire:model="form.email" id="email" class="block mt-1 w-full" type="email"
                              name="email"
                              required autofocus autocomplete="username"/>
                <x-input-error :messages="$errors->get('email')" class="mt-2"/>
            </div>

            <!-- Password -->
            <div class="mt-4">
                <x-input-label for="password" :value="__('Password')"/>

                <x-text-input wire:model="form.password" id="password" class="block mt-1 w-full"
                              type="password"
                              name="password"
                              required autocomplete="current-password"/>

                <x-input-error :messages="$errors->get('password')" class="mt-2"/>
            </div>

            <!-- Remember Me -->
            <div class="block mt-4">
                <label for="remember" class="inline-flex items-center">
                    <input wire:model="form.remember" id="remember" type="checkbox"
                           class="rounded dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-indigo-600 shadow-sm focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:focus:ring-offset-gray-800"
                           name="remember">
                    <span class="ms-2 text-sm text-gray-600 dark:text-gray-400">{{ __('Remember me') }}</span>
                </label>
            </div>

            <div class="flex items-center justify-end mt-4">
                @if (Route::has('password.request'))
                    <a class="underline text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-offset-gray-800"
                       href="{{ route('password.request') }}" wire:navigate>
                        {{ __('Forgot your password?') }}
                    </a>
                @endif

                <x-primary-button class="ms-3">
                    {{ __('Log in') }}
                </x-primary-button>
            </div>
        </form>
    </div>
</section>

0 likes
1 reply
LaryAI's avatar
Level 58

To reuse just the login parts of your Breeze setup on the home page for non-logged-in users, you can extract the login form into a separate Livewire component and then include that component both in the full login page and on the home page.

Here's how you can do it:

  1. Create a new Livewire component for the login form.
php artisan make:livewire LoginForm
  1. Move the login form HTML and the corresponding Livewire logic from your existing full-page component to the new LoginForm component.

Here's an example of what the LoginForm component might look like:

// app/Http/Livewire/LoginForm.php

namespace App\Http\Livewire;

use Livewire\Component;
use Illuminate\Support\Facades\Auth;

class LoginForm extends Component
{
    public $email;
    public $password;
    public $remember;

    protected $rules = [
        'email' => 'required|email',
        'password' => 'required',
    ];

    public function login()
    {
        $this->validate();

        if (Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) {
            session()->regenerate();
            return redirect()->intended(RouteServiceProvider::HOME);
        }

        $this->addError('email', trans('auth.failed'));
    }

    public function render()
    {
        return view('livewire.login-form');
    }
}
  1. Create a new Blade view for the LoginForm component.
{{-- resources/views/livewire/login-form.blade.php --}}

<form wire:submit.prevent="login">
    <!-- Email Address -->
    <div>
        <label for="email">Email</label>
        <input wire:model="email" id="email" type="email" required autofocus>
        @error('email') <span>{{ $message }}</span> @enderror
    </div>

    <!-- Password -->
    <div>
        <label for="password">Password</label>
        <input wire:model="password" id="password" type="password" required>
        @error('password') <span>{{ $message }}</span> @enderror
    </div>

    <!-- Remember Me -->
    <div>
        <label for="remember">
            <input wire:model="remember" id="remember" type="checkbox">
            Remember me
        </label>
    </div>

    <div>
        <button type="submit">Log in</button>
    </div>
</form>
  1. Include the LoginForm component in your full login page and on the home page.

In your full login page:

{{-- Inside your full login page view --}}
<livewire:login-form />

On your home page:

{{-- On your home page view --}}
@auth
    <!-- The user is already logged in, so you might show a different content -->
@else
    <livewire:login-form />
@endauth

Regarding your question about potential conflicts between Breeze and Filament, they serve different purposes and should not conflict with each other. Breeze provides a simple authentication scaffolding, while Filament is an admin panel for Laravel. However, if you encounter any specific issues, you may need to address them on a case-by-case basis.

Remember to run php artisan livewire:discover after creating new Livewire components to ensure they are registered properly.

Please or to participate in this conversation.