1
Expensive,
Can you help me with this portable redirect? I created a method where it re-evaluates the data and redirects, on the other hand when redirecting I get the Route error [clima.consenso.visual.ID] not defined, only that I defined the routes.
//Redireciona
public function redirect( Request $request, Pesquisa $pesquisa )
{
$jaFeito = Consenso::where( 'pesquisa_id', $pesquisa->id )->count() > 0;
if ($jaFeito) {
return redirect()->route( 'clima.consenso.visual.'.$pesquisa->id );
}
return redirect()->route( 'clima.consenso.show' );
}
Route
//Grupo consenso
$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($pesquisas as $pesquisa)
<tr>
<th scope="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>
Thanks guy worked out.
– Ronaldo Adriano