I'm trying to get a successful message informed on a div
while an action is being performed, but I have not yet succeeded, the error that appears is:
(3/3) ErrorException Undefined variable: sucess (View: /opt/lampp/htdocs/projectslaravel/clinica-beta/resources/views/layouts/app.blade.php) (View: /opt/lampp/htdocs/projectslaravel/clinica-beta/resources/views/layouts/app.blade.php)
My code is as follows in 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 controller this way
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');
}
}