本文整理汇总了PHP中app\models\City::getAllCity方法的典型用法代码示例。如果您正苦于以下问题:PHP City::getAllCity方法的具体用法?PHP City::getAllCity怎么用?PHP City::getAllCity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\City
的用法示例。
在下文中一共展示了City::getAllCity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importStuData
public function importStuData($model)
{
$dispResults = [];
$totalSuccess = 0;
$objPHPExcel = PHPExcel_IOFactory::load($model->importFilePath . $model->importFile);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
//print_r($sheetData); exit;
unset($sheetData[1]);
//start import student row by row
foreach ($sheetData as $k => $line) {
//print_r($line); exit;
if (!array_filter($line)) {
continue;
}
$line = array_map('trim', $line);
$line = array_map(function ($value) {
return empty($value) ? NULL : $value;
}, $line);
$stuMaster = new StuMaster();
$stuInfo = new StuInfo();
$stuInfo->scenario = 'import-stu';
$stuAddress = new StuAddress();
$user = new User();
$auth_assign = new AuthAssignment();
//set student info attributes
$stuInfo->stu_unique_id = $stuInfo->getUniqueId();
// Student Unique Id
$stuInfo->stu_title = $this->valueReplace($line['A'], $stuInfo->getTitleOptions());
//Title Name
$stuInfo->stu_first_name = $line['B'];
//First Name
$stuInfo->stu_last_name = $line['C'];
//Last Name
$stuInfo->stu_dob = Yii::$app->dateformatter->getDateFormat($line['D']);
//Date of Birth
$stuInfo->stu_admission_date = Yii::$app->dateformatter->getDateFormat($line['H']);
//Student Admission Date
$stuInfo->stu_gender = $this->valueReplace($line['I'], $stuInfo->getGenderOptions());
// Gender
$stuInfo->stu_email_id = $line['J'];
// Email ID
$stuInfo->stu_mobile_no = $line['K'];
// Mobile No
//set student master attribute
$stuMaster->stu_master_course_id = $this->valueReplace($line['E'], Courses::getStuCourse());
// Course
$stuMaster->stu_master_batch_id = $this->valueReplace($line['F'], Batches::getStuBatches());
// Batch
$stuMaster->stu_master_section_id = $this->valueReplace($line['G'], Section::getStuSection());
// Section
$stuMaster->stu_master_category_id = $this->valueReplace($line['L'], StuCategory::getStuCategoryId());
//Admission Category
$stuMaster->stu_master_nationality_id = $this->valueReplace($line['M'], Nationality::getNationality());
//Nationality
//set student address attribute
$stuAddress->stu_cadd = $line['N'];
//Current Address
$stuAddress->stu_cadd_city = $this->valueReplace($line['O'], City::getAllCity());
//City
$stuAddress->stu_cadd_state = $this->valueReplace($line['P'], State::getAllState());
//State
$stuAddress->stu_cadd_country = $this->valueReplace($line['Q'], Country::getAllCountry());
//Country
$stuAddress->stu_cadd_pincode = $line['R'];
//Pincode
$stuAddress->stu_cadd_house_no = $line['S'];
//House No
$stuAddress->stu_cadd_phone_no = $line['T'];
//Phone No
//set user login info attributes
$uniq_id = $stuInfo->getUniqueId();
$login_id = \app\models\Organization::find()->one()->org_stu_prefix . $uniq_id;
$user->user_login_id = $login_id;
//user login id
$user->user_password = md5($user->user_login_id . $user->user_login_id);
//user password
$user->user_type = "S";
//user type
$user->created_by = Yii::$app->getid->getId();
//created by
$user->created_at = new \yii\db\Expression('NOW()');
//created at
if ($user->validate() && $stuInfo->validate() && $stuAddress->validate()) {
$transaction = Yii::$app->db->beginTransaction();
try {
if ($stuInfo->save() && $user->save() && $stuAddress->save()) {
$stuMaster->stu_master_stu_info_id = $stuInfo->stu_info_id;
$stuMaster->stu_master_user_id = $user->user_id;
$stuMaster->stu_master_stu_address_id = $stuAddress->stu_address_id;
$stuMaster->created_by = Yii::$app->getid->getId();
$stuMaster->created_at = new \yii\db\Expression('NOW()');
if ($stuMaster->save()) {
$stuInfo->stu_info_stu_master_id = $stuMaster->stu_master_id;
if ($stuInfo->save(false)) {
$auth_assign->item_name = 'Student';
$auth_assign->user_id = $user->user_id;
$auth_assign->created_at = date_format(date_create(), 'U');
$auth_assign->save(false);
$transaction->commit();
$totalSuccess += 1;
//.........这里部分代码省略.........