Laravel:如何在Voyager管理面板中使用警报?

时间:2017-07-09 15:03:58

标签: laravel voyager

如何在旅行者中使用警报?举个例子?我希望在提交空白字段时显示提醒。

  • Voyager版本:v0.11.14

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:3)

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

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

或者:

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