I want to have a context like this image:
A unauthenticated user can access the congress details page single.blade.php
and he can select the quantities that he want for each ticket type. After click Next
, if is not authenticated he goes to the "login.blade.php" to login. After login he should be redirected to the registration.blade.php
.
So for the first screen I have this from action and route:
<form method="post"
action="{{route('congresses.registration',
['id' => $congress->id, 'slug' => $congress->slug])}}">
Route::get('/congress/{id}/{slug?}', [
'uses' => 'FrontController@show',
'as' =>'congresses.show'
]);
For the user access the registration page he should be authenticated, so there is this route:
Route::group(['prefix' => '', 'middleware' => 'auth'], function(){
Route::post('/congress/{id}/{slug?}/registration', [
'uses' => 'RegistrationController@storeQuantity',
'as' =>'congresses.registration'
]);
}
Doubt: Do you know which data and what is necessary to store in session so is possible to redirect the user to the registration page after login?
With the code I have for now without using sessions, the user select the quantities and click in "Next", then the user introduce the email and password click in "Confirm" and then the user is redirected to "http://layout.test/congress/1/congress-title-test/registration" but it appears always "Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
".
LoginController:
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function authenticated(Request $request, $user)
{
return redirect()->intended($this->redirectTo);
}
}
Routes:
Middleware group URI NAME ACTION
Get | Head | Web / / App\Http\Controllers\FrontController@index
Get | Head | Web congress/{id}/{slug?} congresses.show App\Http\Controllers\FrontController@show
Get | Head | POST | PUT
| PATCH | DELETE |
OPTIONS | WEB | AUTH congress/{id}/{slug?}/registration congresses.registration App\Http\Controllers\RegistrationController@storeQuantity
I also have the default laravel auth routes.