I'm starting to learn how to use Framework
Laravel
and I'm having a problem with the targeting after login, I'm using the Framework
own login system.
To learn how to use Framework
I am creating a simple blog and at the time of logging in this is directing to the path /admin
same as changing the protected $redirectTo = '/dashboard'
attribute
I would like to know what can be because I could not find the bug ?
As requested by the friends below, follow the code of the routes and class where I changed the redirectTo attribute.
routes / web.php
<?php
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/admin', 'HomeController@index');
Route::group(['prefix' => 'dashboard'], function() {
Route::get('/','DashboardController@index');
});
app \ Http \ Controllers \ Auth \ LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller{
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']);
}
App / Http / Controllers / HomeController
<?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('home');
}
}