In Laravel, the best way to pass different types of flash messages in the session

前端 未结 16 2766
长情又很酷
长情又很酷 2020-12-12 09:51

I\'m making my first app in Laravel and am trying to get my head around the session flash messages. As far as I\'m aware in my controller action I can set a flash message ei

16条回答
  •  被撕碎了的回忆
    2020-12-12 10:56

    If you want to use Bootstrap Alert to make your view more interactive. You can do something like this:

    In your function:-

    if($author->save()){
        Session::flash('message', 'Author has been successfully added');
        Session::flash('class', 'success'); //you can replace success by [info,warning,danger]
        return redirect('main/successlogin');
    

    In your views:-

    @if(Session::has('message'))
        
    @endif
    

提交回复
热议问题