/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Inventorystock::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'brand_id' => $this->brand_id, 'watches_id' => $this->watches_id, 'quantity' => $this->quantity]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getInventorystocks() { return $this->hasMany(Inventorystock::className(), ['watches_id' => 'id']); }
public function actionInventory() { $model = new Inventorystock(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->refresh(); } else { return $this->render('inventory', ['model' => $model]); } }
/** * Finds the Inventorystock model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Inventorystock the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Inventorystock::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }