[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], ]; } /** * Lists all InventoryItem models. * @return mixed */ public function actionIndex($id) { $inventory = Inventory::findOne($id); if ( !isset($inventory)){ throw new NotFoundHttpException("Leltár nem található"); } $searchModel = new InventoryItemSearch(['inventory' => $inventory]); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'model' => $inventory, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } /** * Displays a single InventoryItem model. * @param integer $id * @return mixed */ public function actionView($id) { return $this->render('view', [ 'model' => $this->findModel($id), ]); } /** * Creates a new InventoryItem model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($id) { $model = new InventoryItemForm([ 'id_inventory' => $id ]); $model->read(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['inventory-item/index', 'id' => $model->inventory->id_inventory]); } else { return $this->render('create', [ 'model' => $model, ]); } } /** * Updates an existing InventoryItem model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_inventory_item]); } else { return $this->render('update', [ 'model' => $model, ]); } } /** * Deletes an existing InventoryItem model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $item = $this->findModel($id); $id_inventory = $item->id_inventory; $item->delete(); return $this->redirect(['index', 'id' => $id_inventory]); } /** * Finds the InventoryItem model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return InventoryItem the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = InventoryItem::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }