/** * 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; }
public function search($input) { $query = Suppliers::query(); $columns = Schema::getColumnListing('suppliers'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }
public function buildForm() { $this->add('supplier_id', 'select', ['empty_value' => '- Pilih Supplier -', 'choices' => \App\Models\Suppliers::lists('name_company', 'supplier_id')->toArray(), 'label' => 'Supplier', 'attr' => ['id' => 'supplier_id']])->add('category_id', 'select', ['empty_value' => '- Pilih Kategori -', 'choices' => \App\Models\ItemsCategory::lists('name_category', 'item_category_id')->toArray(), 'label' => 'Kategori Barang', 'attr' => ['id' => 'category_id']])->add('name_items', 'text')->add('unit', 'text')->add('price_buy', 'number', ['default_value' => 0, 'attr' => ['min' => 0], 'label' => 'Harga Beli'])->add('price_selling', 'number', ['default_value' => 0, 'attr' => ['min' => 0], 'label' => 'Harga Jual'])->add('stok', 'number', ['default_value' => 0, 'attr' => ['min' => 0, 'readonly' => 'true'], 'label' => 'Stok'])->add('note', 'textarea'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $Suppliers = Suppliers::findOrFail($id); $Suppliers->delete(); Helper::add($id, 'deleted supplier ' . $Suppliers->title . ' (ID ' . $id . ')'); Session::flash('flash_message', $this->title . ' successfully deleted!'); return Redirect::action('SuppliersController@index'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $currentPeriodId = Helper::defaultPeriodId(); $item = Purchases::findOrFail($id); $periods = StockPeriods::all(); $categories = PurchaseCategory::lists('title', 'id'); $period_list = array(); foreach ($periods as $period) { $period_list[$period->id] = 'Stock #' . $period->number . ' (' . $period->date_from . ' - ' . ($period->id == $currentPeriodId ? 'NOW' : $period->date_to) . ')'; } return view('Purchases.edit')->with(array('title' => $this->title, 'item' => $item, 'stocks_list' => $period_list, 'suppliers' => Suppliers::orderBy('title', 'ASC')->lists('title', 'id'), 'categories' => $categories)); }
/** * 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'); }
/** * Finds the Suppliers model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Suppliers the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Suppliers::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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; }