/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Suppliers::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, 'status' => $this->status, 'uid' => Yii::$app->user->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'area', $this->area])->andFilterWhere(['like', 'remark', $this->remark])->andFilterWhere(['like', 'admin', $this->admin])->andFilterWhere(['like', 'tell', $this->tell])->andFilterWhere(['like', 'addr', $this->addr]); return $dataProvider; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $suppliers = Suppliers::find($id); $suppliers->delete(); // redirect Session::flash('message', 'Berhasil Menghapus Data!'); return Redirect::to('suppliers'); }
private function getAllSupplier() { $supplier = Suppliers::find()->where(['uid' => Yii::$app->user->id])->all(); $supplier_array = array(); foreach ($supplier as $item) { $name = $item->getAttribute('name'); $supplier_array[$name] = $name; } return $supplier_array; }