Search code examples
laravelvoyager

Laravel: How to use alerts in Voyager admin panel?


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

  • Voyager Version: v0.11.14

Solution

  • 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