Redirect failure Laravel

1

Expensive,

Can you help me with this laravel redirect? I created a method where it re-evaluates the data and redirects, on the other hand at the time of redirect I get the error Route [climate.consensus.visual.ID] not defined, only that I defined the routes.

Picture

//Redirecionapublicfunctionredirect(Request$request,Pesquisa$pesquisa){$jaFeito=Consenso::where('pesquisa_id',$pesquisa->id)->count()>0;if($jaFeito){returnredirect()->route('clima.consenso.visual.'.$pesquisa->id);}returnredirect()->route('clima.consenso.show');}

Route

//Grupoconsenso$router->group(['prefix'=>'consenso','as'=>'consenso.'],function($router){/**@var\Illuminate\Routing\Router$router*/$router->get('/',['uses'=>'ConsensoController@index','as'=>'index']);$router->get('/pesquisa/{clima_pesquisa}',['uses'=>'ConsensoController@show','as'=>'show']);$router->post('/pesquisa/{clima_pesquisa}',['uses'=>'ConsensoController@store','as'=>'store']);$router->get('/visual/{clima_pesquisa}',['uses'=>'ConsensoController@visual','as'=>'visual']);$router->get('/redirect/{clima_pesquisa}',['uses'=>'ConsensoController@redirect','as'=>'redirect']);});

View

@forelse($pesquisasas$pesquisa)<tr><thscope="row">
                <a href="{{ route('clima.consenso.redirect', compact('pesquisa')) }}">{{$pesquisa->id}}</a>
            </th>
            <td>
                <a href="{{ route('clima.consenso.redirect', compact('pesquisa')) }}">{{$pesquisa->matricula}}</a>
            </td>
            <td>
                <a href="{{ route('clima.consenso.redirect', compact('pesquisa')) }}">{{mb_convert_case($pesquisa->nome,MB_CASE_TITLE , 'UTF-8' )}}</a>
            </td>
            <td>{{ $pesquisa->updated_at->format('d/m/Y H:i') }}</td>
            <td>
                <button
                        type="button" class="btn">
                    <a href="{{ route('clima.consenso.show', compact('pesquisa')) }}">Avaliar</a>
                </button>
            </td>
        </tr>
    
asked by anonymous 11.09.2018 / 19:35

1 answer

3

The error is correct, the clima.consenso.visual.1127 route does not even exist. The existing route is clima.consenso.visual which receives a clima_pesquisa parameter.

To redirect a Response to a named route simply use redirect('nome.da.rota', ['parametros' => 'da rota']) ;

In your case it would be:

return redirect()->route( 'clima.consenso.visual', ['clima_pesquisa' => $pesquisa->id]);
    
11.09.2018 / 19:58