/**
  *
  */
 private function generateTeachers()
 {
     $genderList = array(Teacher::GENDER_MALE, Teacher::GENDER_FEMALE);
     $prepareItemData = function ($itemNum) use($genderList) {
         return ['Teacher Name ' . $itemNum, $genderList[rand(0, 1)], '+79260000' . rand(100, 999)];
     };
     $this->loadByPortion($prepareItemData, Teacher::tableName(), ['name', 'gender', 'phone'], $this->getConfig('teachers_num'));
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getListWithStudentsCounrt()
 {
     $query = Teacher::find()->joinWith(StudentTeacher::tableName())->addSelect([Teacher::tableName() . '.*', 'COUNT(' . StudentTeacher::tableName() . '.student_id) as student_count'])->groupBy(Teacher::tableName() . '.id');
     return $query;
 }