Laravel Alert Messages

shanisingh03

shani singh

Posted on June 8, 2021

Laravel Alert Messages

Laravel alert

In this post i am going to explain about creating beautiful alert message by using bootstrap alert component.

Let's Create a Common Blade File Called alert.blade.php



{{-- Message --}}
@if (Session::has('success'))
    <div class="alert alert-success alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert">
            <i class="fa fa-times"></i>
        </button>
        <strong>Success !</strong> {{ session('success') }}
    </div>
@endif

@if (Session::has('error'))
    <div class="alert alert-danger alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert">
            <i class="fa fa-times"></i>
        </button>
        <strong>Error !</strong> {{ session('error') }}
    </div>
@endif


Enter fullscreen mode Exit fullscreen mode

Now Use This alert blade file anywhere you want to use.



@include('common.alert')


Enter fullscreen mode Exit fullscreen mode

To Pass the Alert Message in View File you can use.



return redirect()->route('users.index')->with('success', 'User Deleted successfully.');


Enter fullscreen mode Exit fullscreen mode

You can access this code on TechTool India Github Repo.

You can watch the explanation video for more clarity.

To Read about Laravel User Management read below
Part - 1
Part - 2
Part - 3

Thank You for Reading

In case of any query related to LARAVEL.
Reach Out To me.
Twitter
Instagram
TechToolIndia

πŸ’– πŸ’ͺ πŸ™… 🚩
shanisingh03
shani singh

Posted on June 8, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related