Example #1
0
 public function __construct($config)
 {
     $this->device_id = $config['device_id'];
     $this->modelClass = Price::className();
     array_shift($config);
     parent::__construct($config);
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->device_id) {
         $query = Price::find()->where(['device_id' => $this->device_id])->orderBy(['title' => SORT_ASC]);
         $this->_dataProvider = new ActiveDataProvider(['query' => $query]);
     } else {
         throw new InvalidParamException(Module::t('res', 'No device ID given!'));
     }
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPrices()
 {
     return $this->hasMany(Price::className(), ['device_id' => 'id']);
 }
Example #4
0
 /**
  * Finds the model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Price the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Price::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }