Exemple #1
0
 /**
  * Поиск DeckCard модели по первичному ключу
  * Если модель не будет найдена - то 404 ошибка
  * @param integer $id
  * @return DeckCard выбранной модели
  * @throws NotFoundHttpException
  */
 protected function findModel($id)
 {
     if (($model = DeckCard::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #2
0
 /**
  * Load cards by id
  * @param int $id
  */
 public static function load($id)
 {
     if (!isset(self::$cards[$id])) {
         $card = DeckCard::findOne($id);
         $item = $card->getAttributes(['id', 'title', 'description', 'cost', 'type']);
         $item['img'] = $card->img->getThumb('60x80');
         $c = self::getCard($card);
         $c->setAttributes($item);
         unset($card, $item);
         self::$cards[$id] = $c;
     }
     return self::$cards[$id];
 }
Exemple #3
0
 /**
  * Get Cards
  * @param int $number
  * @return array
  */
 public function getCards($number = 1, $info = true)
 {
     $cards = explode(',', $this->cards_list);
     $offset = 0;
     // (int)$this->cards;
     // $this->updateAttributes(['cards' => $offset + $number]);
     $result = array_slice($cards, $offset, $number);
     if ($info) {
         $data = [];
         $items = DeckCard::find()->where(['in', 'id', $result])->all();
         foreach ($items as $item) {
             $i = $item->getAttributes(['id', 'title', 'description', 'cost', 'type']);
             $i['img'] = $item->img->getThumb('60x80');
             $data[] = $i;
         }
         $result = $data;
         unset($data);
     }
     return $result;
 }
Exemple #4
0
        </div>
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'deck_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Deck::find()->all(), 'id', 'title'));
?>

            <?php 
echo $form->field($model, 'img')->imageInput();
?>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'type')->dropDownList(\common\models\DeckCard::getTypes());
?>
        </div>
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'data')->arrayInput();
?>
        </div>
    </div>

    <div class="form-group submit-row">
        <?php 
echo Html::submitButton('Применить', ['class' => 'btn btn-warning', 'name' => 'apply']);
?>
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary', 'name' => 'save']);