1
I’m having a beginner’s difficulty here in my training with Laravel 5.5 I just created an update method - Update,
public function atualizar(Request $request, $id)
{
$dados = $request->all();
if(isset($dados['situacao']))
{
$dados['situacao'] = "Ativa";
}
else
{
$dados['situacao'] = "Inativa";
}
Empresa::find($id)->update($dados);
$mensagem = "Empresa altera com sucesso!";
return redirect()->route('admin.empresas')->with('mensagem', $mensagem);
}
The update is being performed correctly, but the message is not being returned to the screen for an Alert.
This redirect
that I’m using is not correct?
Thanks.
how you’re doing in the view?
– novic
Thus Virgilio:
@if (session('mensagem'))
 <div class="alert alert-success" role="alert">{{$mensagem}}</div>
@endif
– Regis Andrade
do so:
@if (Session::has('mensagem')) <div class="alert alert-success" role="alert">{{session('mensagem')}}</div> @endif
!!!– novic
It didn’t work, message didn’t show up
– Regis Andrade
does so now in the method
return redirect(route('admin.empresas'))->with('mensagem', $mensagem);
I’m in the bank kkk– novic
I just got back here, it didn’t work out either. :(
– Regis Andrade
Put your
View
!– novic
I put in my doubt, look there
– Regis Andrade
First look at my comment, and then tell me does not appear the text? or nothing appears? the Box appears?
– novic
Virgilio I’m sorry, the wrong code, it was not in the form that the message should appear, but in a list.
– Regis Andrade
Then following your Return tip, I had to do the following to get it right
@if (Session::has('mensagem'))
 <div class="alert alert-success" role="alert">{{Session::get('mensagem')}}</div>
 @endif
– Regis Andrade
worked out ?....
– novic
Simmm, thanks for your help
– Regis Andrade