0
I’m trying to get you informed a message of success in a div
when an action is carried out, however I could not yet, the error that appears is:
(3/3) Errorexception Undefined variable: sucess (View: /opt/lampp/htdocs/projetoslaravel/clinica-beta/Resources/views/layouts/app.blade.php) (View: /opt/lampp/htdocs/projetoslaravel/clinica-beta/Resources/views/layouts/app.blade.php)
my code is as follows on the page layout
@if(isset($errors) and count($errors) > 0)
<div id="msg" class="alert alert-error">
<p>{{$error}}</p>
</div>
@elseif(isset($sucess) and count($sucess) > 0)
<div id="msg" class="alert alert-sucess">
<p>{{$sucess}}</p>
</div>
@endif
in the controller as follows
public function ativar($id)
{
$apt = $this->ModelApartamento->find($id);
$liberacao = $apt->verificarAtivar();
if ($liberacao) {
$dados = ['status' => 'L'];
//dd($dados);
$update = $apt->update($dados);
if ($update) {
return redirect()
->back()
->with('sucess','Apartamento ativado com sucesso');
} else {
return redirect()
->back()
->with('errors', 'Ocorreu um erro ao tentar ativar apartamento');
}
} else {
return redirect()
->back()
->with('errors', 'Apartamento está com paciente no momento');
}
}
The variable has not been set, it is set in the controller if there is success of the update, then the correct in your Test is to do "if it is error show otherwise show success" and you are asking for error and success.
– Gabriel Rodrigues