Laravel: 如何在 Voyager 管理面板中使用警报?
Laravel: How to use alerts in Voyager admin panel?
如何在航海者中使用警报?有什么例子吗?我想在 post 提交空字段时显示警报。
- 航海者版本:v0.11.14
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
您可以通过控制器执行如下操作:
return redirect('path')->with(['message' => "Your Success Message", 'alert-type' => 'success']);
或者:
return redirect('path')->with(['message' => "Your Error Message", 'alert-type' => 'error']);
如何在航海者中使用警报?有什么例子吗?我想在 post 提交空字段时显示警报。
- 航海者版本:v0.11.14
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
您可以通过控制器执行如下操作:
return redirect('path')->with(['message' => "Your Success Message", 'alert-type' => 'success']);
或者:
return redirect('path')->with(['message' => "Your Error Message", 'alert-type' => 'error']);