[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], ]; } /** * Lists all City models. * @return mixed */ public function actionIndex($id_card) { $card = $this->findModel($id_card); $searchModel = new MobileDeviceSearch(); $searchModel->id_card = $card->id_card; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'card' => $card ]); } public function actionStatus($id_device, $status) { $device = $this->findDevice($id_device); \Yii::info(print_r($device,true)); if ( $device == null ){ throw new NotFoundHttpException(); } if (\Yii::$app->request->isPost) { $form = new MobileStatusForm(); $form->status = $status; $form->id_device = $id_device; if ($form->validate()) { $form->save(); return $this->redirect(['mobile-device/index', 'id_card' => $device->id_card]); } } return $this->render( 'mobile-device/index',[ 'id_card' => $device->id_card]); } /** * Finds the Card model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Card the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Card::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } /** * @param $id * @return MobileDevice|null * @throws NotFoundHttpException */ protected function findDevice($id) { if (($model = MobileDevice::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }