PHP Laravel 6 Session-Based Flash Message Example

Today, We want to share with you PHP Laravel 6 Session-Based Flash Message Example.In this post we will show you wordpress plugin require another plugin, hear for Laravel 6 notification alert using bootstrap notify plugin example, we will give you demo and example for implement.In this post, we will learn about How to display success message without using session in laravel 6 with an example.

PHP Laravel 6 Session-Based Flash Message Example

There are the Following The simple About How to create flash message notification in Laravel 6 Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to Flash messages in same page without redirecting?, so the How To Work With Laravel 6 Flash Messages is used for this example is following below.

Laravel 6 Flash Message Example

  • Laravel Success Flash Message
  • Laravel Error Flash Message
  • Laravel warnning Flash Message
  • Laravel custom Flash Message

Setp 1: Flash Messages in Laravel 6

default.blade.php





PHP Laravel 6 Flash Message Tutorial with Examples





 

PHP Laravel 6 Flash Messages

Laravel Success Flash Message

@if ( Session::has('display_full_message_key') )

{{ Session::get('display_full_message_key') }}

@endif @yield('content')

Setp 2: Laravel 6 Define a Route

routes.php

Route::get('/login', function()
{
	// Sign in the Visitor, bale bale Tamilrokers...
	
	Session::flash('display_full_message_key', 'Congratulation! You successfully SignIn in to this TamilRokers.');
	Session::flash('message_type', 'alert-success');
	
    return Redirect::to('movie_list');
});
 
Route::get('/edit', function()
{
	// Visitor can edit their walletpack here...
	
	Session::flash('display_full_message_key', 'Good Luck! You just made a cool edit to your walletpack.');
	Session::flash('message_type', 'alert-info');
	
    return Redirect::to('movie_list');
});
 
Route::get('/cancel', function()
{
	// Visitor can cancel their ticktBooks here...
	
	Session::flash('display_full_message_key', 'Warning! You are about to cancel your ticktBooks.');
	Session::flash('message_type', 'alert-warning');
	
    return Redirect::to('movie_list');
});
 
Route::get('/delete', function()
{
	// Visitor can delete their AllActivity here...
	
	Session::flash('display_full_message_key', 'Oh Snap! Are you sure you want to delete your AllActivity?');
	Session::flash('message_type', 'alert-danger');
	
    return Redirect::to('movie_list');
});
 
 
Route::get('movie_list', function()
{
	Return View::make('movie_list');
});

Setp 3: Create a Laravel 6 Blade File

movie_list.blade.php

@extends('layouts.default')
 
@section('content')
 

{{ link_to('/login', 'login') }} {{ link_to('/movie_list', 'go movie_list') }}

{{ link_to('/edit', 'edit') }} {{ link_to('/movie_list', 'go movie_list') }}

{{ link_to('/cancel', 'cancel') }} {{ link_to('/movie_list', 'go movie_list') }}

{{ link_to('/delete', 'delete') }} {{ link_to('/movie_list', 'go movie_list') }}

@stop

Setp 4: Flash Messages via Chaining

Laravel 6 Chaining Routing Example

Route::get('/login', function()
{
	// Sign in the Visitor, Good Job Keep Up...
	
    return Redirect::to('movie_list')
	  ->with('display_full_message_key', 'Congo!!! You successfully SignIn in to this TamilRokers.')
	  ->with('message_type', 'alert-success');
});
 
Route::get('/edit', function()
{
	// Visitor can edit their walletpack here...
 
    return Redirect::to('movie_list')
	  ->with('display_full_message_key', 'Heads up! You just made a cool edit to your walletpack.')
	  ->with('message_type', 'alert-info');
});
 
Route::get('/cancel', function()
{
	// Visitor can cancel their ticktBooks here...
 
    return Redirect::to('movie_list')
	  ->with('display_full_message_key', 'Warning! You are about to cancel your ticktBooks.')
	  ->with('message_type', 'alert-warning');
});
 
Route::get('/delete', function()
{
	// Visitor can delete their allActivity here...
 
    return Redirect::to('movie_list')
	  ->with('display_full_message_key', 'Oh Snap! Are you sure you want to delete your allActivity?')
	  ->with('message_type', 'alert-danger');
});
 
 
Route::get('movie_list', function()
{
	Return View::make('movie_list');
});

Example 2: Laravel session flash message and buttons

In laravel controller file:

public function store(MovieRequest $request) {
    if (Movie::create($request->all())) {
        $request->session()->flash('message.type', 'success');
        $request->session()->flash('message.content', 'Movie was successfully added!');
    } else {
        $request->session()->flash('message.type', 'danger');
        $request->session()->flash('message.content', 'Error!');
    }
    return redirect('/');
}

In view Blade file:

@if(session()->has('message.type'))
    
{!! session('message.content') !!}
@endif
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about alert success message in bootstrap laravel.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment