Laravel 5.3 notification message popup using toastr js plugin with demo

Laravel 5.3 notification message popup using toastr js plugin with demo

Laravel 5.3 notification message popup using toastr js plugin with demo

In this post, I will tell you how to show notification alert box using toastr js in Laravel.

By using toastr plugin, you can display message notification for success, info, warning with awesome layout that means you can easily display your error message or success message with title to user by using toastr plugins.

There are so many plugins available with laravel to show notification message on each activity like growl and flash messages.

You always need to display notification to user either user register in your website or you are going to add/update/delete any records.

With toastr notification, you can easily customize their layout with bootstrap.

Follow below steps to see how its working in laravel application :

Step 1: Add route

In this step simply add below route in your web.php.

routes/web.php
Route::get('notification', 'UserController@notification');
Step 2: Create UserController

In this step, create a controller if you haven't and then add notification method within UserController.

app/Http/Controllers/UserController.php
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Http\Requests;
  5. class UserController extends Controller
  6. {
  7. public function notification(){
  8. $notification = array(
  9. 'message' => 'Thanks! We shall get back to you soon.',
  10. 'alert-type' => 'success'
  11. );
  12. session()->set('notification',$notification);
  13. return view('notification');
  14. }
  15. }
Step 3: Create Layout for toastr notification

Now create a notification.blade.php in view directory.

resources/views/notification.blade.php
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Laravel notification message popup using toastr js plugin with demo</title>
  5. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  6. <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css">
  7. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
  8. <script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
  9. </head>
  10. <body>
  11. <div class="container">
  12. <div class="row">
  13. <div class="col-md-12">
  14. <div class="panel panel-primary">
  15. <div class="panel-heading">Dashboard</div>
  16. <div class="panel-body">
  17. Check for toastr notification
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <script>
  24. @if(Session::has('notification'))
  25. alert("{{ Session::get('notification.alert-type') }}");
  26. var type = "{{ Session::get('notification.alert-type', 'info') }}";
  27. switch(type){
  28. case 'info':
  29. toastr.info("{{ Session::get('notification.message') }}");
  30. break;
  31. case 'warning':
  32. toastr.warning("{{ Session::get('notification.message') }}");
  33. break;
  34. case 'success':
  35. toastr.success("{{ Session::get('notification.message') }}");
  36. break;
  37. case 'error':
  38. toastr.error("{{ Session::get('notification.message') }}");
  39. break;
  40. }
  41. @endif
  42. </script>
  43. </body>
  44. </html>

Click here to see another demo to submit contact form with toastr notification.

Submit Contact Form in PHP Laravel 5 with toastr notifications jquery

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
gaziantep escort antep escort porno
avcılar escort