Can’t find Controller’s method

Asked

Viewed 82 times

0

I was testing some features on the project site that I am doing in MVC, but it has a function that is not working anymore. When accessing the site it says:

"Method App Http Controllers updates::ret_user() does not exist"

Route:

Route::get("/update_user", "updates@retorna_usuario")->middleware('login');

But I do have this method in the controller:

 class updates extends Controller
{
  public function retorna_usuario()
    {
        $cargo = session('cargo');
        $prontuario = session('prontuario');
        $perfil = DB::table("users")->where('prontuario', '=', $prontuario)->OrderBy('nome')->first();
        if($cargo == "A")
        return view('editar.update_admin')->with('perfil', $perfil);        
        if($cargo == "P" || $cargo == "O")
        return view("editar.update_user")->with('perfil', $perfil);
    }}

What’s wrong with the code? I’ve used the composer update in the prompt but it’s still making that mistake. What should I do?

  • Are you with Artisan to serve? Reset, log out and turn on Artisan

  • Yes! Already used the Artisan serves this running.

  • Hang up and turn on, try again

  • What controller namespace? And what folder is it in?

  • I restarted the computer but it is still the same. The other controllers that are in the same folder are working. The namespace is namespace App Http Controllers; same as other controllers

  • What is the controller file called? should be called updates.php

  • Yes, it is called updates.php

  • Put Updatescontroller.php and the Updatescontroller class and also change the changes on the route... It has a pattern... It has a shape but there is something else

  • Boy, try writing your controller as follows: Route::get('/updates_user', array('as'=>'namenaota','uses'=>'updates@returns_user)); and see if it works. By the way, I would like you to run php Artisan Routes

  • Guys, it was hopeless, I did what you suggested, but it didn’t work. I had a project backup prior to this problem and restored and the problem solved. The strange thing is that even deleting the controller still gave the same exception

  • No way, I did what you suggested but it didn’t work. I had a backup of the project before this problem and I restored and the problem solved. The strange thing is that even deleting the controller it still gave the same exception. Thanks for all the help.

  • One thing you can do is recompile

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.