6 months ago

"Call to undefined method" of a clearly defined method?

Posted 6 months ago by uccdev

I have a class IndexController class with its own method verifyUser.

 public function verifyUser($user) {
     echo "Test!";

Its actual code isn't as important as the nature that it isn't called when I want it to be.

It works perfectly fine in its base class, but when I try to call it in other classes I get different results:

   $this->indexController = new IndexController();

I can confirm that auth()->user() is fine. The error message I get is something else: Call to undefined method: IndexController::verifyUser()

I can reword the call in a few different ways, such as:



 $thing = $this->indexController->verifyUser(auth()->user());

But it doesn't fit it.

I note that if I simply paste the code that verifyUser has into my new class, it works just fine. It's just this one form of method calling. I don't get why it works. Could anyone shed some light on why I might be getting this issue?

Please sign in or create an account to participate in this conversation.