DEV Community

Cover image for Laravel Alert Messages
shani singh
shani singh

Posted on

7

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (1)

Collapse
 
thallesrangel profile image
Thallesrangel

Thanks bro.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay