How do i redirct to login?

Hi!

Ii i have a button, that I only want signed in users to be to use. How can I redirect to login page?

In your routes/web.php file

Route::group(['middleware' => ['auth']], function () {
 //route that only authenticated users can use
 //another route
});

within a blade view you can use:
@auth
//stuff
@endauth

@guest
  //stuff
@endguest

Laravel Docs

Thanks for your reply! The button goes to a Livewire controller. So I need either flash a modal or redirect to the login page.

wire:click=“modalLogic”

inside component class:

public $modalOn = false;

public function modalLogic()
{
    if(Auth::check()) {
       //user is logged in
       $this->modalOn = true;
    }
    else {
       //guest
       return redirect(route('login'));
    }
}
1 Like