0

I can login and register with laravel-8 after login or register it takes me to the dashboard which is an automated generated page with auth in laravel -8 named dashbord.blde.php but after login I want to go to my index.blade.php page path of this page is resource/views/prducts/index.blade.php. Thanks in advance. :) here in my web.php

Route::get('/', function () {
    return view('welcome');
});

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');

2 Answers2

0

If you take a look at the app/Http/Controllers/Auth/LoginController.php file, for example, you would find the following code:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{

    use AuthenticatesUsers;

    protected $redirectTo = '/home';

    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

You can see that a $redirectTo variable exists and has the value of /home where users are redirected after they are logged in.

In this case, you should change it to protected $redirectTo = '/dashboard';

stolen with respect from : https://www.techiediaries.com/laravel-auth-redirection-using-redirectto/

0

Following the contribution above, you can change the '/home' redirect to '/products/index', and in the web.php declare this route

Route::get('/products/index', function(){
    return view('products.index');
})->name('products_index');
Prospero
  • 1,932
  • 2
  • 3
  • 17