Is it possible to temporarily disable event in Laravel?

前端 未结 7 1602
轮回少年
轮回少年 2020-12-16 10:21

I have the following code in \'saved\' model event:

Session::flash(\'info\', \'Data has been saved.\')` 

so everytime the model is saved I

7条回答
  •  借酒劲吻你
    2020-12-16 10:39

    Call the model Object then call unsetEventDispatcher after that you can do whatever you want without worrying about Event triggering

    like this one:

        $IncidentModel = new Incident;
        $IncidentModel->unsetEventDispatcher();
    
        $incident = $IncidentModel->create($data);
    

提交回复
热议问题