Beispiel #1
0
 private function internalSave($runValidation, $attributeNames)
 {
     if (!parent::save($runValidation, $attributeNames)) {
         return false;
     }
     for ($i = 0, $cnt = count($this->temy); $i < $cnt; ++$i) {
         $zct = new ZanyatieChastiTemy();
         $zct->zanyatie = $this->id;
         $zct->tema = $this->temy[$i];
         $zct->chast_temy = $this->chasti_tem[$i];
         if (!$zct->save()) {
             return false;
         }
     }
     return true;
 }
Beispiel #2
0
 /**
  * @param Zanyatie $zanyatie
  * @param ZanyatieChastiTemy|null $zct
  * @return bool
  * @throws BadRequestHttpException
  */
 private function saveZanyatieWithZct($zanyatie, $zct)
 {
     $zctsForCheck = $zct ? [$zct] : $zanyatie->getZanyatiya_chastej_tem_rel()->all();
     if ($zanyatie->getHasIntersectOthers($zctsForCheck)) {
         throw new BadRequestHttpException('Intersects with others');
     }
     if (!$zanyatie->save()) {
         return false;
     }
     if ($zct !== null) {
         $zct->zanyatie = $zanyatie->id;
         if (!$zct->save()) {
             return false;
         }
     }
     return true;
 }