public function actionDrop() { $list = \app\models\BalanceItem::find()->all(); foreach ($list as $item) { $item->delete(); } $list = \app\models\BalanceSheet::find()->all(); foreach ($list as $item) { $item->delete(); } return $this->redirect(['index']); }
public function beforeValidate() { if (parent::beforeValidate()) { // ...custom code here... if ($this->order_num == null) { $this->order_num = BalanceItem::find()->where(['balance_type_id' => $this->balance_type_id])->max('order_num') + 1; } $this->order_code = $this->balanceType->order_code . $this->order_num; return true; } else { return false; } }