How do i redirct to login?


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:


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.


inside component class:

public $modalOn = false;

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