In my Controller file, only the 'Return View' is being read, the next code goes straight through and ends.
public function naocadastrado()
{
return View('/naocadastrado');
$user = new \App\User();
$user->Name = Input::get('Name');
$user->User = Input::get('User');
$user->Password = hash('sha256', Input::get('Password'));
$user->Tipo = Input::get('tipo_usuario');
if("SELECT COUNT(*) AS total FROM tabela WHERE campo='User'"){
return redirect('/cadastroexistente');
}else{
return redirect('/cadastrado');
}
$user->save();
}
public function naocadastrado()
{
return View('/naocadastrado');
}
public function ncadastrado()
{
$user = new \App\User();
$user->Name = Input::get('Name');
$user->User = Input::get('User');
$user->Password = hash('sha256', Input::get('Password'));
$user->Tipo = Input::get('tipo_usuario');
if("SELECT COUNT(*) AS total FROM tabela WHERE campo='User'"){
return redirect('/cadastroexistente');
}else{
return redirect('/cadastrado');
}
$user->save();
}
I've divided:
WEB.PHP
Route::group (['prefix' => '', 'namespace' => 'Api'], function(){
Route::get('/naocadastrado', 'CadastroController@naocadastrado');
Route::post('/naocadastrado', 'CadastroController@ncadastrado');
});
BLADE
<body>
<form method="POST" action="/ncadastrado">
<h1> Cadastro de Usuários UNIUS <br> </h1>
<h2> USUÁRIO NÃO CADASTRADO<br> CADASTRE-SE! </h2>
<label><b>Nome:</label> <input type="text" name="Name"> <br>
<label><b>E-mail:</label> <input type="text" name="User"> <br>
<label>Senha:</label> <input type="password" name="Password" > <br>
<label>Tipo de usuário</label>
<select name="tipo_usuario">
<option value="">Selecione</option>
<option value="Administrador">Administrador</option>
<option value="Desenvolvedor">Desenvolvedor</option>
</select><br><br>
<input type="submit" value="Cadastrar" id="cadastrar" name="cadastrar">
</form>
</body>