2

flash messages not visible in the view section, after adding these lines in the Kernel.php.

protected $middleware = [
    \App\Http\Middleware\CheckForMaintenanceMode::class,
    \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
    \App\Http\Middleware\TrimStrings::class,
    \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
    \App\Http\Middleware\TrustProxies::class,
    \Illuminate\Session\Middleware\StartSession::class,      //Line no 1 added
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,    //Line no 2 added
];

Here is my working code, which is correct before adding these lines.

Controller Code:

return redirect('/admin/categories')->with('success','Record Successfully Added.');

View Code:

@if ($message = Session::get('success'))
{{ $message }}

These lines are also necessary for me, I can't remove it. Can anybody have the solution, please let me know. Thanks for advance!

Vaibhav Singhal
  • 511
  • 1
  • 4
  • 25

0 Answers0