【问题标题】:Toast Notification in LaravelaLaravel 中的 Toast 通知
【发布时间】:2020-04-24 16:38:28
【问题描述】:

我是编程新手,我被分配建立一个租赁系统。我正在使用 laravel,我很难发出 toast 通知。我不知道当客户成功提交表单时如何调用toast(bootstrap) 通知。

这是我的控制器,其中数据已成功提交到数据库中。

public function store(Request $request){

    $rentform = new BorrowerRequest;
    $rentform->user_id = $request->user_id;
    $rentform->car_id = $request->car_id;
    $rentform->borrowers_name = $request->borrowers_name;
    $rentform->email = $request->email;
    $rentform->return_date = $request->return_date;
    $rentform->contact_number = $request->contact_number;
    $rentform->request_status_id = $request->request_status_id;


    $rentform->save();
    $request->session()->flash('message', 'Your Request has been successfully submitted, please wait for a couple of hours for the approval');

    return redirect('/selections');
}

任何人都可以给我一个提示,告诉我如何设置一个条件,即每当客户提交表单请求时,管理员帐户中就会弹出一个 toast 通知?

【问题讨论】:

    标签: php laravel-5 bootstrap-toast


    【解决方案1】:

    你可以使用This包来通知toastr,成功后 安装这个包你需要在你的链接那些css和js cdn 主模板..

    <link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css">
    
    <script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
        {!! Toastr::message() !!}
    

    然后您可以使用此通知,例如,

    $rentform->save();
        Toastr::success('Post Successfully Saved :)','Success');
        return redirect('/selections');
    

    并确保您需要在控制器中使用此行

    use Brian2694\Toastr\Facades\Toastr;
    

    欲了解更多详情,请访问此链接::

    https://packagist.org/packages/brian2694/laravel-toastr

    【讨论】:

    • 嗨。感谢 Md Foysal,我已经在我的作曲家“composer require brian2694/laravel-toastr”中输入了这个命令,但它说 [InvalidArgumentException] 找不到包 brian2694/laravel-toaster。你是这个意思吗? brian2694/laravel-toastr .. 你认为是什么原因造成的?
    • composer 需要 brian2694/laravel-toastr 只需使用这个...
    • 你也可以手动添加这些行到你的项目中......而不是仅仅运行这个命令来发布...... php artisan vendor:publish
    猜你喜欢
    • 2016-09-26
    • 1970-01-01
    • 1970-01-01
    • 2014-10-07
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多