Update Active Record

public function actionDemo(){

       // post value into the 


           $id = explode(',', $_POST['cuttoffKey']);

           $date = $_POST['Cutt-off'];

           DemoTable::updateAll(['status' => DemoTable::STATUS_ORDER_ACCEPTED, 'cut_off_date' => $date], ['id' => $id]);


           Yii::$app->session->setFlash('Success', 'Selected Orders are successfully saved !!!');


           Yii::$app->session->setFlash('Warning', 'Error Occured !!! Try Again !!!');


       return  $this->redirect(['new-order']);



when i am Update database using this query

DemoTable::updateAll([‘status’ => DemoTable::STATUS_ORDER_ACCEPTED, ‘cut_off_date’ => $date], [‘id’ => $id]);

beforeSave() is not called.

but using foreach for saving the query , there is no problem with beforeSave().

for example.

foreach($data as $i => $value){

$value->save(); // beforeSave() is working


Because updateAll() does not call beforeSave() method.

Thanks :)