private function getRecordsByPhoneNumber($number) { $phone_record = PhoneRecord::findOne(['number' => $number]); if (!$phone_record) { return []; } $customer_record = CustomerRecord::findOne($phone_record->customer_id); if (!$customer_record) { return []; } return [$this->makeCustomer($customer_record, $phone_record)]; }
/** * Finds the CustomerRecord model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CustomerRecord the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CustomerRecord::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }