Home > Blockchain >  returning controller not found when using it as "controller@method" in laravel
returning controller not found when using it as "controller@method" in laravel

Time:07-07

I'm trying to make the resource route of steps work with id passed in the link like this "/steps/{howitwork:id}/create" and the create method looks like this:

public function create(HowItWork $how){
  ...
}

so before I define the resource route in the controller:

Route::get('steps/{howitwork:id}/create/', [
   'as' => 'steps.create',
   'uses' => 'StepController@create'
]);

what the app returning is:

Target class [StepController] does not exist.

CodePudding user response:

you have add code under the resource route and try with this.

**Route::resrouce('something', SomethingController::class);
**Route::get('steps/{howitwork}/create', [StepController::class, 'create'])->as('steps.create');

CodePudding user response:

I suggest you to use this syntax:

Route::get('/', [YourController::class, 'your-method'])->name('your-route-name')->middleware(['your-middleware-1', 'your-middleware-2', 'your-middleware-3']);
  • Related