I have a simple test routine, which is not working in the final part. The idea is to query a MySql database and compose a page with the result, which works correctly.
By clicking on a link in a line of this composite page, line data should be displayed.
To do this, the link must pass its value to a new search routine, in order to query the database again to collect more information, since the list obtained initially only contains summarized data.
This part does not work. It results in error:
Sorry, the page you are looking for could not be found. NotFoundHttpException in RouteCollection.php line 161:
The route code for page calls looks like this:
<?php
Route::get('/', function () {
return view('welcome');
});
Route::get('usuarioLer','controllerUsuarios@pesquisar');//pesquisa todo o BD
Route::get('usuarioDetalhar/{nome}','controllerUsuarios@detalhar');//pesquisa um item no BD
Route::group(['middleware' => ['web']], function () {
});
?>
The 'route' userLer is the one that works 100%. This route, as noted, calls the page controllerUsuarios.php and causes the search method.
A fragment of this php page is:
public function pesquisar (){
$listaUsuarios = DB::select
("SELECT * from usuarios INNER JOIN categorias ON
usuarios.TabFKUsuariosCategoria = categorias.TabCategoriasID");
return view('viewUsuariosLista')->with('listaU',$listaUsuarios);
}//metodo pesquisar
The above code calls a 'view' page through the return, which displays the result of all the records in the database.
The viewUsuariosLista.php page has the following code:
<?php
echo <<<BLOCO1
<html>
<head>
<!-- <link href="../public/css/app.css" rel="stylesheet"> -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<script src="assets/js/bootstrap.min.js"></script>
</head>
<body>
<table class="table">
BLOCO1;
foreach ($listaU as $u){
echo "<tr>";
echo "<td>".$u->TabUsuariosID."</td>";
echo "<td>".$u->TabUsuariosNome."</td>";
echo "<td>".$u->TabCategoriasDescricao."</td>";
echo "<td><a href='usuarioDetalhar?nome=".$u->TabUsuariosNome."'>
<span class='glyphicon glyphicon-search'></span></a></td>";
echo "</tr>";
}//foreach
echo <<<BLOCO2
</table>
<br />
</body>
<html>
BLOCO2;
?>
Repeating, so far everything works 100%.
Now, come the error. By clicking the link generated by the line
echo "<td><a href='usuarioDetalhar?nome=".$u->TabUsuariosNome."'>
<span class='glyphicon glyphicon-search'></span></a></td>"
It causes the user's 'route' call to be specified, passing the 'name' variable to the name of the user clicked. The 'route', as shown above and here I repeat
Route::get('usuarioDetalhar/{nome}','controllerUsuarios@detalhar');//pesquisa um item no BD
does not work, causing the mentioned error.
The view 'view' page viewUsuariosDetalhes.php exists, and its simple code is
<html>
<head>
</head>
<body>
<h1>Detalhes do Usuário <br />
<h3><?php echo($u->TabUsuariosNome);?></h3>
</h1>
</h1>
<ul>
<li>
<b>Categoria:</b><?php echo($u->TabCategoriasDescricao); ?>
</li>
</ul>
</body>
</html>