dimanche 28 février 2016

Laravel 5 flash message keep appearing

I'm using flash for users feedback after the user successfully (or failed) in creating an article. I'm using PHP version 5.5.27. Here is my store function in controller :

public function store(ArticleRequest $request)
{

    $data = $request->all();

    Article::create($data);

    Flash::message('Article Created!');

    return redirect ('articles');

}

and here is the app.blade.php in my view :

<div class="container">

@include('flash::message')

@yield('content')

I've tried using the original Session::message and it's still the same. I've also tried all the solution from Laravel 5 flash message flashes again after navigating away and using back button and it still didn't fix my problem. But when I tried creating a new fresh laravel project it did work nicely. I'm having the TokenMismatchException before this problem and fixing it by editing the VerifyCsrfToken.php file like below :

public function handle($request, Closure $next)
{
    //return parent::handle($request, $next);

    $response = $next($request);

    if (last(explode('\\',get_class($response))) != 'RedirectResponse') {
        $response->header('P3P', 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
    }

    return $response;

}

Is this problem related to VerifyCsrfToken.php file? How can I fix that? Any help would be appreciated



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire