/** * Finds the Classes model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Classes the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Classes::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionUpdateList($id) { $this->checkAccess('admin_staff'); $post = Yii::$app->request->post(); $model = Classes::findOne((int) $id); $dataProvider = new ActiveDataProvider(['query' => TransactionHistory::find()->where(['class_id' => $id, 'transaction_dispute_status' => 'open'])]); if (!empty($post)) { switch ($post['Classes']['class_name']) { case 'approved': TransactionHistory::setRefundDispute($model); TransactionHistory::sendEmailStudentList($model); break; } TransactionHistory::updateAll(['transaction_dispute_status' => $post['Classes']['class_name']], ['class_id' => $id, 'transaction_dispute_status' => 'open']); return $this->redirect('/dispute/list'); } else { return $this->render('update-list', ['model' => $model, 'dataProvider' => $dataProvider]); } }