3

How to use alerts in voyager? any example? I want to show alert when post submitting with empty fields.

  • Voyager Version: v0.11.14
Miri
  • 976
  • 1
  • 9
  • 15

2 Answers2

8

From a controller you can do something like this:

return redirect('path')->with(['message' => "Your Success Message", 'alert-type' => 'success']);

Or:

return redirect('path')->with(['message' => "Your Error Message", 'alert-type' => 'error']);
Momo
  • 141
  • 4
  • 8
6

Voyager uses toastr Library, and to use it simply you can fire it as an event using following ways :

Toastr::warning($message, $title = null, $options = []) - add a warning toast
Toastr::error($message, $title = null, $options = []) - add an error toast
Toastr::info($message, $title = null, $options = []) - add an info toast
Toastr::success($message, $title = null, $options = []) - add a success toast
Toastr::add($type: warning|error|info|success, $message, $title = null, $options = []) - add a toast
Toastr::clear() - clear all current toasts
Abhinav Verma
  • 425
  • 7
  • 14