0

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.

  • you need to either use the FQCN (`App\Http\Controllers\Auth\RegisterStep2Controller`) or add a namespace to the route group that you have there or in your `RouteServiceProvider` (`Route::namespace('App\Http\Controllers')->group(....)`) then you can reference the Controller from that namespace forward (`Route::get(..., ['Auth\RegisterStep2Controller', 'method'])`) – lagbox May 31 '22 at 20:27
  • Maybe you didnt import it right. Dont puth auth in the route line. Just get the namespace completely and then get it into the route – Noble Eugene May 31 '22 at 20:54

1 Answers1

0

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');