About Routes and Links

1

I made a crud, but I changed the organization of the files, instead of following the pattern, I created a user folder that contains the controller, route and model. I'd like help trying to figure out why I can not find the route through link_to_route.

routes.php

Route::resource('/', '\App\Usuario\Http\Controllers\UsuariosController');

users / index.blade.php

@foreach ($usuarios as $usuario)
<tbody>
    <tr>
        <td>{{$usuario->nome}}</td>
        <td>{{$usuario->sobrenome}}</td>
        <td>{{$usuario->email}}</td>
        <td>{{$usuario->usuario}}</td>
        <td>{{$usuario->created_at}}</td>
        <td>{{$usuario->updated_at}}</td>
        <!--É necessário uma rotas nomeada-->
        <td>{{ link_to_route('edit', $title = 'Editar', $usuario->id, $attributes = []) }}</td>
    </tr>
</tbody>
@endforeach

This is the error:

NotFoundHttpException in RouteCollection.php line 161
    
asked by anonymous 05.04.2016 / 16:54

4 answers

1

First of all I would like to thank Evert and Vinicius Luiz.

The solution I found was as follows:

Since within the view I was with another directory in which I called Users > Index.blade.php

The link_to_route modified by putting the name of the view + index to:

<td>{{ link_to_route('usuarios.edit', $title = 'Editar', $usuario->id) }}</td>

The routes continued like this:

Route::resource('usuarios', '\App\Usuario\Http\Controllers\UsuariosController');
    
14.04.2016 / 16:40
1

Try changing to:

Route::get('/' , 'UsuariosController@metodoDoControllerUtilizado');

This should work for you.

    
06.04.2016 / 16:29
1

In your view it will look something like this:

<td>{{ route('usuarios.edit' , [$title => 'Editar' , 'ID_USUARIO' => $usuario->id]) }}</td>

And your route will be as follows:

Route::get('usuarios' , ['as' => 'usuarios.edit' , 'UsuariosController@METODO']);
    
14.04.2016 / 16:47
0

Create the structure you want, update your namespace , remove the path and leave only

Route::resource('/', 'UsuariosController');

Your controller needs to extend to the Controller class.

Make one:

composer dump-autoload

Please try again and see if it works.

I hope I have helped.

    
06.04.2016 / 16:09