Problem with exception laravel 5.5

-1

I have a small problem with an exception, which is with a route, for example.

I have this route, which loads well.

link

but if I make a change like this.

link

I'm loading an error

Now, in the other modules and routes, if I make changes like these, I load the exception, but I do not understand why this route does not.

I point out the route with which I have the problem.

My method.

 /**
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function create(Request $request)
    {
      
        $request->user()->authorizeRoles(['admin']);
        return view('usuario.create');
       
    }
    

Route file

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Route::get('/panel', 'PanelController@index');
Route::get('/panel/filtusuario', 'CuentaController@filtusuario')->name('usuario.filtusuario');
Route::post('/panel/gestion', 'CuentaController@ugestion')->name('usuario.ugestion');
Route::post('/panel/bestado', 'CuentaController@bestado')->name('usuario.bestado');
Route::post('/panel/selectord', 'CuentaController@selectord')->name('usuario.selectord');
Route::get('/panel/revisar', 'CuentaController@revisar')->name('cuenta.revisar');
Route::post('/panel/estado', 'CuentaController@cestado')->name('cuenta.cestado');
Route::post('/panel/asignar', 'CuentaController@asignar')->name('cuenta.asignar');
Route::get('/panel/tareas', 'CuentaController@tareas')->name('cuenta.tareas');
Route::get('/panel/inactivo', 'CuentaController@inactivo')->name('cuenta.inactivo');
Route::get('/panel/reportes', 'CuentaController@reportes')->name('cuenta.reportes');
Route::resource('/panel/ecuentas', 'CuentaController');
Route::resource('/panel/registros', 'RegistrosController');
Route::get('/panel/fecha', 'UsuarioController@fecha')->name('usuario.fecha');
Route::post('/panel/selector', 'UsuarioController@selector')->name('usuario.selector');
Route::post('/panel/cedula', 'UsuarioController@cedula')->name('usuario.cedula');
Route::resource('/panel/usuario', 'UsuarioController');
Auth::routes();  

The route is updated to exclude the show method, but now this appears.

I give an example, with a route that works for me, for example I have this one.

link

which I'm calling with this route, user.index, is also a method of UserController, and if I do this.

link , upload this to me

It is also a resource type method, and it works well, it is assumed that the other route should work the same, but I do not know what happens.

    
asked by zereft 02.01.2019 в 19:02
source

1 answer

2

In the capture of the list of routes it is clearly observed what happens:

  • When writing / panel / user / createrrr, this path is not equal to / panel / user / create, so continue to explore the following routes.
  • The next defined path is / panel / user / {user}, so Laravel will try to find the user «createrrr» to pass it to the show() method of the controller UsuarioController , according to the syntax of the written path : / panel / user / createrrr.
  • Finally, the error says that the show() method does not exist in this controller, so you have two options to solve the problem:

    • The question is not very well posed but I assume that you want to show an exception, so you must remove the show method from the resource to prevent Laravel from continuing to use that route:

      Route::resource('/panel/usuario', 'UsuarioController')->except(['show']);
      
    • In case you need the show() method, you must define it in the controller and rethink your routes.
  • answered by 02.01.2019 / 19:13
    source