samedi 6 juin 2020

Cannot get Session message from Handler class laravel

What I try to do is to get a message in the session when redirecting back to the page from exception handler class, When I get 'PostTooLargeException' It should back to page with a message.

** If statement in Handler class**

public function render($request, Exception $exception)
    {
        //...

        if ($exception instanceof PostTooLargeException) {


           $test = redirect()->route('clientbank.create')->with('message', 'File too large!'); //Cannot get message
           return $test;
           //dump($gg);
           dump(session('message'));
           dd('stop');

        }
        // this will still show the error if there is any in your code.

        return parent::render($request, $exception);
    }
}

In dump(session('message')); I can see the message .

enter image description here

**In blade page **

   @elseif(session('message'))
     <div class="alert alert-danger alert-dismissible fade show" role="alert">
       
     <button type="button" class="close" data-dismiss="alert" aria-label="Close">
       <span aria-hidden="true">&times;</span>
     </button>
     </div>
   @endif

What I try to do is use empyt(session('message') I always get an empty session.

Also, I try this questions but not work for me.

I use laravel 5.8

Any ideas, please.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UcvgyP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire