Laravel does not return variable passed by with

-1

Hello, how are you? Why Laravel is not picking up the object in the view. Searching 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
    
asked by anonymous 11.07.2016 / 03:26

2 answers

0
return redirect()->action('UserController@profile', ['id' => 1]);

Test this.Using this structure.

    
11.07.2016 / 13:30
0

You're using wrongly, in accordance with documentation , try this form:

$deleted = $prod->delete();

return redirect()->action('ProdutoController@lista', ['deleted' => $deleted]);

and in the view:

@if ($deleted)
    Removido com sucesso.
@endif

You can take a look at in this answer and follow some tips that I recommended myself, one of them is to use English as the base language.

    
11.07.2016 / 18:57