Skip to content
Advertisement

Laravel 8: Argument 2 passed must be an instance of

I’m working with Laravel 8 to develop an Online Forum. And I made this form for updating an answer of a user:

JavaScript

And here is the route for this:

JavaScript

And this is also the Method of QuestionController:

JavaScript

But now the problem is, whenever I submit the form in order to update answer, I get this as error:

Argument 2 passed to AppHttpControllersQuestionController::updateAnswer() must be an instance of AppModelsQuestion, string given, called in F:xampphtdocsgooyanetrootvendorlaravelframeworksrcIlluminateRoutingController.php on line 54

I don’t why I get this error, because as you can see I have passed $que->id at Action to Question $que as the 2nd parameter of udpateAnswer() method.

So what is your idea about this? How can I solve this issue?

I would really appreciate if you share your idea or suggestion with me.

Thanks…

Advertisement

Answer

It is because your variable in the controller is called $anss and in your route is called ans

Check this answer I have given in another topic.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement