Ejemplo n.º 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.');
     }
 }
Ejemplo n.º 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];
 }