/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Auctions::find()->joinWith([ 'company0', 'auctionsCriterias', 'bidsTerms' ]); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); $dataProvider->pagination->pageSize=$this->pageSize; 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([ 'duration' => $this->duration, 'auctions.amount' => $this->amount, 'auctions.status' => $this->status, ]); $query->andFilterWhere(['like', 'auctions.name', $this->name]) ->andFilterWhere(['like', 'companies.name', $this->companyName]) ->andFilterWhere(['like', 'auctions.create_date', $this->create_date]); return $dataProvider; }
public function actionListAuctions($term){ $array = Auctions::find()->select('id,name') ->where(['like' , 'name' , $term]) ->asArray()->all(); return Json::encode($array); }
/** * Finds the Auctions model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Auctions the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Auctions::find()->joinWith([ 'bidsTerms', 'auctionsCriterias' ])->where([ 'auctions.id' => $id ])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/* @var $model auction\models\Lots */ /* @var $form yii\widgets\ActiveForm */ ?> <?php Pjax::begin(['id' => 'brand-form','enablePushState' => false, 'timeout' => false])?> <?php $form = ActiveForm::begin([ 'id' => 'create-brand', 'action' => Auction::createUrl('company/lots/create'), 'fieldClass' => 'auction\widgets\ActiveField', 'options' => [ 'data-pjax' => 1, ], ]); ?> <fieldset> <?= $form->field($model, 'name')->textInput() ?> <?= $form->field($model, 'auction')->dropDownList(ArrayHelper::map(Auctions::find()->all(),'id','name'),['class' => 'form-control']) ?> <?= $form->field($model, 'condition')->textInput() ?> <?= $form->field($model, 'is_quantity')->textInput() ?> <?= Html::submitButton('Create a new lot',['class' => 'btn btn-lg btn-info btn-block'])?> </fieldset> <?php ActiveForm::end(); ?> <?php Pjax::end();?>
/** * Updates an existing Auctions model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed * * @throws Exception 404 if invalid data provided */ public function actionUpdate($id) { $model = Auctions::find()->joinWith([ 'bidsTerms', 'auctionsCriterias', 'auctionPreferences' ])->where([ 'auctions.id' => $id ])->one(); if($model === null){ throw new HttpException(404 ,' Not A valid Auction'); } $post = Auction::post(); if ($model->load($post) && $model->bidsTerms->load($post) && $model->auctionsCriterias->load($post) && $model->auctionPreferences->load($post)) { if($model->save() && $model->bidsTerms->save() && $model->auctionsCriterias->save() && $model->auctionPreferences->save()){ return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->render('update', [ 'model' => $model, ]); } }