Error Route [teacher.actualizarusuario] not defined. "

1

I have routes defined

Route::patch('misvistas/docente/{id}', 'DocenteController@actualizarusuario');
Route::resource('misvistas/docente', 'DocenteController');

Running php artisan route:list appears in the user update list.

But when trying to run the "update user" function, the error occurs:

Route [docente.actualizarusuario] not defined.
    
asked by Ricardo Garcia Olais 25.12.2017 в 05:54
source

2 answers

1

You are creating the route as follows:

Route::patch('misvistas/docente/{id}', 'DocenteController@actualizarusuario');

But because of the error it gives you, you are trying to call it by an alias or name that has never been declared ( docente.actualizarusuario ):

Route [docente.actualizarusuario] not defined.

To be able to use the alias of the route, you must first declare it with name() , leaving the definition of the route like this:

Route::patch('misvistas/docente/{id}', 'DocenteController@actualizarusuario')->name('docente.actualizarusuario');
    
answered by 26.12.2017 / 11:31
source
0

Testing with Laravel 5.1 I did not find any errors.

With the routes you indicate:

Route::patch('misvistas/docente/{id}', 'DocenteController@actualizarusuario');
Route::resource('misvistas/docente', 'DocenteController');

And a controller like the following:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;


class DocenteController extends Controller
{

    public function index()
    {
        echo(get_class() . ' / index() <hr>');
    }

    public function actualizarusuario($id)
    {
        echo(get_class() . ' / actualizarusuario() -> ID: ' . $id . '<hr>');
    }

    public function show($id)
    {
        echo(get_class() . ' / show() -> ID: ' . $id . '<hr>');
    }


} //class

If you make the GET request:

http://tuapp.com/misvistas/docente/1

You get:

  

App \ Http \ Controllers \ DocentController / show () - > ID: 1

If you make the PATCH request (and have previously disabled the CSRF protection *):

http://tuapp.com/misvistas/docente/1

You get:

  

App \ Http \ Controllers \ DocentController / updateuser () - > ID: 1

When listing routes using artisan:

php artisan route:list

appears among others the route you have defined:

PATCH    | misvistas/docente/{id}           |
   | App\Http\Controllers\DocenteController@actualizarusuario

Check that you are using the correct verb in the request and your controller to see if you have any difference.

* Disable CSRF protection (only for local tests, re-activate later): Go to the class "app / Http / Kernel.php" and comment the property line $middleware :

\App\Http\Middleware\VerifyCsrfToken::class,
    
answered by 26.12.2017 в 00:04