title: How can i redirect to dashboard after login in laravel 8
body: <p>Iam new in laravel and i want to redirect to rout (dashboard) after login, can i make it ?</p>
  <p>iam tried many of methods but not work with me</p>
  <p>this RedirectIfAuthenticated.php file</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Middleware;
  
  use Closure;
  use Request;
  use App\Providers\RouteServiceProvider;
  use Illuminate\Support\Facades\Auth;
  
  class RedirectIfAuthenticated
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @param  string|null  $guard
       * @return mixed
       */
  
  
  public function handle($request, Closure $next, $guard = null)
      {
          if (Auth::guard($guard)-&gt;check()) {
  
              return redirect(RouteServiceProvider::DASH);
          }
          return $next($request);
      }
  
  
  }
  </code></pre>
  <p>this LoginController.php file</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\Auth;
  
  use App\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  use Illuminate\Http\Request;
  class LoginController extends Controller
  {
      /*
      |--------------------------------------------------------------------------
      | Login Controller
      |--------------------------------------------------------------------------
      |
      | This controller handles authenticating users for the application and
      | redirecting them to your home screen. The controller uses a trait
      | to conveniently provide its functionality to your applications.
      |
      */
  
      use AuthenticatesUsers;
  
      /**
       * Where to redirect users after login.
       *
       * @var string
       */
      protected $redirectTo = 'dashboard';
      
  
      /**
       * Create a new controller instance.
       *
       * @return void
       */
      
      public function __construct()
      {
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
  
      
  }
  </code></pre>
  <p>this RoutServerProvider file</p>
  <pre><code>&lt;?php
  
  namespace App\Providers;
  
  use Illuminate\Support\Facades\Route;
  use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  
  class RouteServiceProvider extends ServiceProvider
  {
      /**
       * This namespace is applied to your controller routes.
       *
       * In addition, it is set as the URL generator's root namespace.
       *
       * @var string
       */
      protected $namespace = 'App\Http\Controllers';
      public const HOME = '/';
      public const DASH = '/dashboard';
      /**
       * Define your route model bindings, pattern filters, etc.
       *
       * @return void
       */
      public function boot()
      {
          //
  
          parent::boot();
      }
  
      /**
       * Define the routes for the application.
       *
       * @return void
       */
      public function map()
      {
          $this-&gt;mapApiRoutes();
  
          $this-&gt;mapWebRoutes();
  
          $this-&gt;mapSiteRoutes();
  
          $this-&gt;mapAdminRoutes();
  
          //
      }
  
      /**
       * Define the &quot;web&quot; routes for the application.
       *
       * These routes all receive session state, CSRF protection, etc.
       *
       * @return void
       */
      protected function mapWebRoutes()
      {
          Route::middleware('web')
               -&gt;namespace($this-&gt;namespace)
               -&gt;group(base_path('routes/web.php'));
      }
  
      protected function mapSiteRoutes()
      {
          Route::middleware('web')
               -&gt;namespace($this-&gt;namespace)
               -&gt;group(base_path('routes/site.php'));
      }
  
      protected function mapAdminRoutes()
      {
          Route::namespace($this-&gt;namespace)
               -&gt;group(base_path('routes/admin.php'));
      }
      /**
       * Define the &quot;api&quot; routes for the application.
       *
       * These routes are typically stateless.
       *
       * @return void
       */
      protected function mapApiRoutes()
      {
          Route::prefix('api')
               -&gt;middleware('api')
               -&gt;namespace($this-&gt;namespace)
               -&gt;group(base_path('routes/api.php'));
      }
  }
  </code></pre>
  <p>My Routs file site.php</p>
  <pre><code>&lt;?php
  use App\Article;
  use App\Http\Controllers;
  /*
  |--------------------------------------------------------------------------
  | Site Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register web routes for your application. These
  | routes are loaded by the RouteServiceProvider within a group which
  | contains the &quot;web&quot; middleware group. Now create something great!
  |
  */
  
  Auth::routes();
  Route::get('/', 'HomeController@index')-&gt;name('home');
  
  Route::group(['prefix' =&gt; 'dashboard','middleware' =&gt; 'guest:api'], function () {
      Route::get('/', 'HomeController@admin_index')-&gt;name('dashboard');
      Route::get('add', 'manage@AddArticle')-&gt;name('addarticle');
      Route::post('add', 'manage@AddArticle')-&gt;name('addpostarticle');
      Route::get('view', 'manage@view')-&gt;name('viewarticle');
      Route::get('read/{id}', 'manage@read')-&gt;name('read');
      Route::post('read/{id}', 'manage@read')-&gt;name('postread');
      Route::get('delete/{id}','manage@DeleteArticle');
      Route::post('edit/{id}', 'manage@Edit')-&gt;name('edit');
      Route::get('edit/{id}','manage@Edit');
      Route::get('articles','ArticleController@index');
      
  });
  </code></pre>