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">×</span></button>
Usuario creado exitosamente
</div>
@endif
The redirect works perfectly but the message doesn't appear.
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">×</span></button>
Usuario creado exitosamente
</div>
@endif
Also, please provide use the route to /usuarios
and the function that belongs to this route.
I tested and it work
@if(Session::get('message') == "store")
sdlsdklskdl
@endif
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');
});