I am absolutly new in Laravel and I have the following problem. I am using Laravel 5.3 .
When I perform the login from my login page it automatically land me on this home page:
http://localhost:8000/home
My doubt is: how can I change the landing page after a success login?
I have these routes:
Andrea@Andrea-PC MINGW64 ~/Documents/Betrivius/WorkSpace/betriviusExtranet (master)
$ php artisan route:list
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
| | GET|HEAD | / | | App\Http\Controllers\LoginBetriviusController@index | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | POST | doLogin | | App\Http\Controllers\LoginBetriviusController@doLogin | web |
| | GET|HEAD | home | | App\Http\Controllers\HomeController@index | web,auth |
| | POST | login | | App\Http\Controllers\Auth\LoginController@login | web,guest |
| | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest |
| | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web |
| | POST | password/email | | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest |
| | GET|HEAD | password/reset | | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\ResetPasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token} | | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest |
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web,guest |
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
So I tried to modify my LoginController (related to the App\\Http\\Controllers\\Auth namespace) changing this value from:
protected $redirectTo = '/home';
to:
protected $redirectTo = '/dashboard-hotel';
where dashboard-hotel represents the dashboard-hotel.php view that I want to open just after a success login.
But doing in this way I obtain the following error message:
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 766
at Router->findRoute(object(Request)) in Router.php line 621
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\Users\Andrea\Documents\Betrivius\WorkSpace\betriviusExtranet\public\index.php') in server.php line 21
This is my /routes/web.php file content:
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
Route::get('/', 'LoginBetriviusController@index');
Route::post('/doLogin', 'LoginBetriviusController@doLogin');
Auth::routes();
Route::get('/home', 'HomeController@index');
So, what is wrong? What am I missing? How can I fix this issue?
Add Route::get('/dashboard-hotel', 'DashboardHotelController@index');
to your /routes/web.php
Create a file in app/Http/Controllers named DashboardHotelController.php
Put this content there
<?php namespace App\\Http\\Controllers; class DashboardHotelController extends Controller { /** * Create a new controller instance. * DashboardHotelController constructor. */ public function __construct() { $this->middleware('auth'); } /** * Show the application dashboard. * @return \\Illuminate\\Http\\Response */ public function index() { return view('dashboard-hotel'); } }
Create a file in your resources/views folder named dashboard-hotel.blade.php
Write there your HTML/Blade code
Do not forget to open terminal and type composer dump-autoload -o
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.