public function validateDoubleMedic($attribute, $params) { $validatequery = Trmaschedule::findOne(['Date' => $this->Date, 'MedicaladvID' => $this->MedicaladvID]); if ($validatequery && $validatequery->mascheduleID != $this->mascheduleID) { $this->addError($attribute, 'The Medical Advisor has another booking in the designated time.'); } }
/** * Finds the Trmaschedule model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Trmaschedule the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Trmaschedule::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }