【问题标题】:Laravel: How to use alerts in Voyager admin panel?Laravel:如何在 Voyager 管理面板中使用警报?
【发布时间】:2017-12-13 08:20:39
【问题描述】:

如何在 voyager 中使用警报?有什么例子吗?我想在提交带有空字段的帖子时显示警报。

  • 航海者版本:v0.11.14

【问题讨论】:

    标签: laravel voyager


    【解决方案1】:

    从控制器你可以做这样的事情:

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

    或者:

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

    【讨论】:

      【解决方案2】:

      Voyager 使用 toastr 库,要简单地使用它,您可以使用以下方式将其作为事件触发:

      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
      

      【讨论】:

        猜你喜欢
        • 2021-06-26
        • 1970-01-01
        • 2020-09-27
        • 2020-11-27
        • 2019-01-01
        • 2018-01-26
        • 1970-01-01
        • 2018-04-19
        • 2019-04-20
        相关资源
        最近更新 更多