Example #1
0
 public function getAttachedToLink()
 {
     if (Attachment::isStorehouse($this->attached_to)) {
         return 'На складі';
     }
     if (Attachment::isRepaired($this->attached_to)) {
         return 'В ремонті';
     }
     if (Attachment::isSoldier($this->attached_to)) {
         $soldier = Soldier::findOne($this->attached_to_soldier);
         return Html::a(Html::encode("Службовець: {$soldier->nickname} ({$soldier->name})"), ['/soldier/view', 'id' => $soldier->id]);
     }
     if (Attachment::isUnit($this->attached_to)) {
         $unit = Unit::findOne($this->attached_to_unit);
         $soldier = Soldier::findOne($unit->soldier);
         return Html::a(Html::encode("Підрозділ: {$unit->name} ({$soldier->nickname}({$soldier->name}))"), ['/unit/view', 'id' => $unit->id]);
     }
     return 'undefined';
 }
Example #2
0
 public function getSoldierLink()
 {
     $s = Soldier::findOne($this->soldier);
     return Html::a(Html::encode("{$s->nickname} ({$s->name})"), ['/soldier/view', 'id' => $s->id]);
 }
Example #3
0
 /**
  * Finds the Soldier model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Soldier the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Soldier::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }