mardi 18 octobre 2016

How to logout and redirect to login page using Laravel 5.3

I am using Laravel 5.3 and trying to implement authentication system. I used php artisan command make:auth to setup it. I edited the views according to my layout and redirecting it my dashboard page instead of home (set as default in setup). Now, when I am trying to logout it throwing me this error

NotFoundHttpException in RouteCollection.php line 161

My code in routes/web.php is:

Auth::routes();

Route::get('/pages/superadmin/dashboard', 'HomeController@index');

HomeController.php

<?php

 namespace App\Http\Controllers;

 use Illuminate\Http\Request;

 class HomeController extends Controller
 {
/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('auth');
}

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    return view('dashboard');
}
}

Auth/Login Controller.php

<?php

namespace App\Http\Controllers\Auth;

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

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->middleware('guest', ['except' => 'logout']);
}
}

I tried the solutions on this page: How to set laravel 5.3 logout redirect path? but it didn't work and showing these errors:

 ReflectionException in Route.php line 339:
 Class App\Http\Controllers\Auth\Request does not exist

I want to redirect it to login page which is in auth/ folder. Please help me.

Thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire