I have fix the problem.
I have just need to redirect to strings, not using the route() method.
Thanks a lot! You have been very, very helpful. :)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone. I'm trying to redirect my users after login, depending about their role (roles are in a column in users table).
(I didn't tell you but I'm using 5.4, sorry)
So, this is my LoginController (the built-in make:auth controllers and middleware, etc)
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
//protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
protected function redirectTo()
{
$UserId = Auth::id();
if(Auth::check() && Auth::user()->role == 'Inquilino')
{
return redirect()->route('workspace',['id' => $UserId]);
}
elseif (Auth::check() && Auth::user()->role == 'Propietario')
{
return redirect()->route('dashboard',['id' => $UserId]);
}
}
}
& then, my Routes file
Route::group(['namespace' => 'Profiles'], function() {
/*Landlords*/
Route::get('/workspace','LandlordController@workspace')->name('workspace');
Route::get('/profile{id}','LandlordController@getProfile');
Route::post('/profile','LandlordController@postProfile');
/*Tenants*/
Route::get('/tdashboard/{id}','TenantController@mainDashboard')->name('dashboard');
Route::get('/bio{id}','TenantController@getProfile');
Route::post('/bio','TenantController@postProfile');
});
The error is:
ErrorException in Response.php line 380: Header may not contain more than a single header, new line detected
in Response.php line 380
at HandleExceptions->handleError(2, 'Header may not contain more than a single header, new line detected', '/home/carlos/Documents/laravel54/newRo/vendor/symfony/http-foundation/Response.php', 380, array('this' => object(RedirectResponse), 'values' => array('http://localhost:8000/HTTP/1.0 302 Found Cache-Control: no-cache, private Location: http://localhost:8000/tdashboard/4 <!DOCTYPE html><html> <head> <meta charset="UTF-8" /> <meta http-e
I really need to redirect to these two specific routes because I need to show my "landlords" & "tenants" how much is their profile percentage complete.
What have I tried?
1.- overwrite the redirectPath method in trait RedirectUsers 2.- disable the middleware 3.- write my logic inside the middleware 4.- write my redirectTo method in LoginController above the constructor... 5.- Followed this https://laracasts.com/discuss/channels/general-discussion/laravel-5-redirect-to-url-after-registration?page=1
BUT the problem is that I'm calling two views at the same time & I don't know how am I doing this?
5.- Convert me in a monk an leave my country... :(
please, help! thank you!
I have fix the problem.
I have just need to redirect to strings, not using the route() method.
Thanks a lot! You have been very, very helpful. :)
Please or to participate in this conversation.