0

I'm trying to send a message when I created an user but I don't get anything..I'm using laravel 5.2

In my controller got this

return redirect('/usuarios')->with('message','store');

in my view I got this

<?php $message=Session::get('message')?>

@if($message == 'store')
    <div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  Usuario creado exitosamente
    </div>  
@endif

The redirect works perfectly but the message doesn't appear.

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

0

Not sure if this fixes the problem, but in Laravel 5.2 you can use this syntax within Blade:

@if(session('message') && session('message') == "store")
    <div class="alert alert-success alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  Usuario creado exitosamente
    </div> 
@endif

Also, please provide use the route to /usuarios and the function that belongs to this route.

Joshua - Pendo
  • 4,331
  • 6
  • 37
  • 51
  • I fixed thanks, in laravel 5.2 its work different. the problem was The way middlewares work has changed from 5.2 and 5.1. In 5.1, you will see this in your app/Http/Kernel.php http://stackoverflow.com/questions/34420590/laravel-5-2-validation-errors?rq=1 – Jorge D. Jesus Jan 22 '16 at 03:27
0

I tested and it work

@if(Session::get('message') == "store")
    sdlsdklskdl
@endif
Viet Nguyen
  • 2,285
  • 2
  • 26
  • 43
-1

Javascript Alert solution laravel 5.2

Route::group(['middleware' => ['web']], function () {

Route::get('/','FrontController@index');
Route::get('contacto','FrontController@contacto');
Route::get('reviews','FrontController@reviews');
Route::get('admin','FrontController@admin');
Route::resource('usuario','UsuarioController');

});
  • Welcome to Stack Overflow! While this code may answer the question, providing additional context regarding why and/or how it answers the question would significantly improve its long-term value. Please [edit] your answer to add some explanation. – CodeMouse92 Apr 15 '16 at 02:25