如何在Laravel中广播消息

时间:2018-12-02 11:28:31

标签: php laravel-5

控制器的存储功能成功后,我试图向所有用户广播消息或通知。

public function store(Request $request,$id)
   {
      if(Auth::check()){

          $permit = Permit::where('id',$id)->first();
          if ($permit)
           {
             $request->validate([
                 'invoice_no' => 'required|string|max:255',    
             ]);

             $invoice = Invoice::insert([
                'invoice_no' => $request->input('invoice_no'),  
                'invoice_date' => $request->input('invoice_date'),  
                'permit_id' => $permit->id,    
                'created_at' => Carbon::now(),                    
             ]);

             if($invoice){
                $permit->invoiced = 1;
                $permit->save();
                $users = User::where('user_type','superadmin')->get();
                $message = "Permit number ".$permit->permit_no." invoiced successful!";
                foreach ($users as $user) {

                    // Need to implement a method here to notify all users

                }
                return redirect()->route('invoices.index')
                    ->with('success' , 'successFull');
             }
         }
         return back()->withInput()->with('errors', 'Error Exists!');
     }
  }

$ message 是我要通知所有用户的消息。

我想使用 bootstrap-notify 包之类的内容来显示消息。如何做到这一点?我已经完成了一些教程,但是它使用了Vue.js,我现在不想跳入Vue.js。因此,如果有其他解决方案,请回复。

0 个答案:

没有答案