/** * @return array */ public function actions() { $actions = parent::actions(); $actions['index']['modelClass'] = 'app\\models\\Stats'; $actions['index']['prepareDataProvider'] = function () { $page = Yii::$app->request->get('page', 1) - 1; $pageSize = Yii::$app->request->get('per-page', 10); return new ArrayDataProvider(['allModels' => Stats::findAll($pageSize, $page * $pageSize, $total), 'totalCount' => $total, 'pagination' => ['pageSize' => $pageSize]]); }; $actions['create']['modelClass'] = 'app\\models\\Stats'; $actions['view']['modelClass'] = 'app\\models\\Stats'; return $actions; }
public function getStats() { return $this->hasMany(Stats::className(), ['deck_types_id' => 'id']); }
/** * Finds the Stats model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Stats the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Stats::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }