/** * Поиск 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.'); } }
/** * 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]; }