public function init() { parent::init(); $this->activeRelationMap = [\app\records\PodrazdelKursa::className() => PodrazdelKursa::className(), \app\records\Zanyatie::className() => Zanyatie::className()]; }
/** * @param $data * @param $nomer * @param $tema * @param $chastTemy * @param KursForm $kurs * @return array */ private function createZanyatie($data, $nomer, $tema, $chastTemy, $kurs) { $zanyatie = new Zanyatie(); $zct = new ZanyatieChastiTemy(); $zanyatie->data = $data; $zanyatie->nomer = $nomer; $zct->tema = $tema; $zct->chast_temy = $chastTemy; $temaRecord = Tema::findOne($tema); $zanyatie->setDefaultsFromKurs($kurs, $temaRecord); return [$zanyatie, $zct]; }
public function getZanyatiya_rel() { $q = (new Query())->select(['zct.zanyatie', 'r.kurs'])->from('zanyatie_chasti_temy zct')->leftJoin('tema t', 't.id = zct.tema')->leftJoin('podrazdel_kursa p', 'p.id = t.podrazdel')->leftJoin('razdel_kursa r', 'r.id = p.razdel'); return Zanyatie::customFind()->leftJoin(['q' => $q], 'q.zanyatie = zanyatie.id')->where(['q.kurs' => $this->id]); }