In this tutorial I’m going to solve how to use Toaster notification in laravel when condition is execute.
First use below cdn
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
![](https://www.devopsfreelancer.com/blog/wp-content/uploads/2023/06/image-16-1024x457.png)
Then put below code in script tag like below.
<script>
@if(Session::has('message'))
toastr.options =
{
"closeButton" : true,
"progressBar" : true
}
toastr.success("{{ session('message') }}");
@endif
@if(Session::has('error'))
toastr.options =
{
"closeButton" : true,
"progressBar" : true
}
toastr.error("{{ session('error') }}");
@endif
@if(Session::has('info'))
toastr.options =
{
"closeButton" : true,
"progressBar" : true
}
toastr.info("{{ session('info') }}");
@endif
@if(Session::has('warning'))
toastr.options =
{
"closeButton" : true,
"progressBar" : true
}
toastr.warning("{{ session('warning') }}");
@endif
</script>
![](https://www.devopsfreelancer.com/blog/wp-content/uploads/2023/06/image-17-1024x553.png)
Next go to blade page and put below code
![](https://www.devopsfreelancer.com/blog/wp-content/uploads/2023/06/image-18-1024x532.png)
Next go to controller and put below code.
![](https://www.devopsfreelancer.com/blog/wp-content/uploads/2023/06/image-19.png)
$notification = array(
'message' => 'Brand Inserted Successfully',
'alert-type' => 'success',
);
return redirect()->back()->with($notification);
Now toastr set successfully.
![](https://www.devopsfreelancer.com/blog/wp-content/uploads/2023/06/image-20-1024x395.png)