laracasts/flash Easy Flash Messages for Laravel 5.2 Application

laracasts/flash Easy Flash Messages for Laravel 5.2 Application

In this post we will give you information about laracasts/flash Easy Flash Messages for Laravel 5.2 Application. Hear we will give you detail about laracasts/flash Easy Flash Messages for Laravel 5.2 ApplicationAnd how to use it also give you demo for it if it is necessary.


If you want to send a notification to the user who performed some action in your application then you may use flash messaging.

The notification could be like that “Good job, Item has been created.” Or: “You are now logged in.” This requires a way to store things in the session within a single request. The way of handling the process is given below:


Installation

First, you need to install the package in your application through Composer to use flash functionality.

You can directly run following command to pull flash package :

composer require laracasts/flash

Or

You can add libraries in composer.json file and then update composer by following command :

Add below line of code in your composer file :

"laracasts/flash": "^2.0"

Run composer update command :

composer update

Now add service provider within config/app.php file.


'providers' => [
    LaracastsFlashFlashServiceProvider::class,
];



Usage

Add flash message in controller before you perform redirect that means before redirecting to url or route set the flash message.

  • public functionAuth()
  • {
  • flash('Welcome to onlinecode!');
  • returnredirect()->route('dashboard');
  • }
public function Auth()
{
    flash('Welcome to onlinecode!');

    return redirect()->route('dashboard');
}


To show this flash message in view include flash in layout view

@include('flash::message')

You can also pass the class name to flash message to display message in different styles.

  • flash('Your message','info')
  • flash('Your message','success')
  • flash('Your message','danger')
  • flash('Your message','warning')

This is the best way to show notification to user on each activity.

Hope this code and post will helped you for implement laracasts/flash Easy Flash Messages for Laravel 5.2 Application. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  32  =  35

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US