Home > Mobile >  How to use web route for auth controller in laravel 8
How to use web route for auth controller in laravel 8

Time:06-05

I wanted to use multi step registration. But got trouble at route. This is my first route.

Route::get('register-step2', [Auth\RegisterStep2Controller::class,'showForm']);
Route::post('register-step2', [Auth\RegisterStep2Controller::class, 'postForm'])
  ->name('register.step2');

but it got error

Target class [Auth\RegisterStep2Controller] does not exist.

so I change and mix with this code.

Route::group(['middleware' => ['auth']], function() {
    Route::resource('roles', RoleController::class);
    Route::resource('users', UserController::class);
    Route::resource('products', ProductController::class);
    Route::get('register-step2', [RegisterStep2Controller::class,'showForm']);
Route::post('register-step2', [RegisterStep2Controller::class, 'postForm'])
  ->name('register.step2');

But it says that: Target class [RegisterStep2Controller] does not exist.

How to use controller in auth in laravel 8 or 9.

I wanted to use registerstep2 controller in auth folder.

CodePudding user response:

Make changes in your routes/web.php as per below

use App\Http\Controllers\Auth\RegisterStep2Controller;
...

Route::get('register-step2', [RegisterStep2Controller::class,'showForm']);
Route::post('register-step2', [RegisterStep2Controller::class, 'postForm'])->name('register.step2');
  • Related