Reputation: 310
Hello guys beauty? Because Laravel is not returning the object in view. Seeking the session I can get the data.
/* ProdutoController */
public function deleta($id){
$prod = Produto::find($id);
$prod->delete();
return redirect()->action('ProdutoController@lista')
->with('message2','deletado');
}
View
@if(!empty($message2))
Deletado com sucesso
@endif
Upvotes: 0
Views: 33
Reputation: 3538
you can check the session variable if exist.
@if (session()->has('message2'))
Deletado com sucesso
@endif
Upvotes: 1
Reputation: 3819
The redirect with() method flashes data to the session. It does not pass the variable directly to your view. Try the following
@if(!empty(session('message2'))
Deletado com sucesso
@endif
Upvotes: 2