Beispiel #1
0
 public function setTankGunLine($gunString)
 {
     $fullname_list = explode(';', $gunString);
     foreach ($fullname_list as $fullname) {
         $attributes = Gun::parseFullName($fullname);
         if (Gun::find()->where(['gun_caliber' => $attributes[0], 'gun_name' => $attributes[1]])->exists()) {
             //echo 'нашли!';
             $guns[] = Gun::findOne(['gun_caliber' => $attributes[0], 'gun_name' => $attributes[1]]);
         } else {
             //echo 'НЕ нашли - надо создать';
             $gun = new Gun();
             $gun->gun_caliber = $attributes[0];
             $gun->gun_name = $attributes[1];
             $gun->save();
             $guns[] = $gun;
         }
         $this->setTankGuns($guns);
     }
 }