/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProductConfig::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([ 'company' => Auction::company(), ]); return $dataProvider; }
/** * Displays a single Auctions model. * @param integer $id * @return mixed */ public function actionView($id) { $model = Auctions::find()->joinWith([ 'bidsTerms', 'auctionsCriterias', 'company0', 'auctionPreferences' => function($query){ $query->joinWith(['category0','brand0']); } ])->where([ 'auctions.id' => $id , 'auctions.company' => Auction::company()] )->one(); if($model == null){ throw new HttpException(404 , 'Not Found'); } return $this->render('view', [ 'model' => $model, ]); }
/** * @param $params * * Search Auction of company using session value of user.company * * @return ActiveDataProvider */ public function companyAuction($params){ $dataProvider= $this->search($params); $dataProvider->query->andWhere([ 'companies.id' => Auction::company() ]); return $dataProvider; }
<?php Pjax::begin(['id' => 'brand-form','enablePushState' => false, 'timeout' => false])?> <?php $form = ActiveForm::begin([ 'id' => 'create-brand', //'action' => Url::to(['brand/create']), 'options' => [ 'data-pjax' => 1, ], 'enableClientValidation' => false ]); ?> <?= $form->field($model, 'name')->textInput() ?> <?= $form->field($model, 'cat_id')->dropDownList(Auction::dropDownList('auction\models\Categories', 'id', 'name')) ?> <?= $form->field($model, 'brand_id')->dropDownList(Auction::dropDownList('auction\models\Brands', 'id', 'name')) ?> <?= $form->field($model, 'company')->hiddenInput(['value' => Auction::company()])->label(false) ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => ($model->isNewRecord) ? 'btn btn-success' : 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?> <?php Pjax::end();?> </div>
public function validate($data = null){ $this->name=$data['Name']; $this->image=$data['Image']; $this->prize=$data['Price']; $this->condition=$data['Condition']; $this->summary=$data['Summary']; $this->quantity=$data['Quantity']; $this->brand=implode(array_slice($data, 7, 1),''); $this->brand_id = array_search($this->brand , $this->BrandList()); $this->category=implode(array_slice($data, 6, 1),''); $this->cat_id = array_search($this->category , $this->CategoryList()); $this->company= Auction::username(); $this->c_id = Auction::company(); $extraCondition = array_slice($data, 8 , count($data)); $extraCond= []; foreach($extraCondition as $key=>$value){; $extraCond[]=[$key => $value]; } $this->extra_cond = $extraCond; return parent::validate(); }
/** * @return mixed|null primary key of created Auction Model */ private function loadAuction(){ $model= new Auctions(); $model->company = Auction::company(); return $this->saveModel($model); }
/** * @param $params * * Search Users of company using session value of user.company * * @return ActiveDataProvider */ public function companyUser($params){ $dataProvider= $this->search($params); //Getting Session Value of user.company Saved During Login Time is user is company/company_admin $dataProvider->query->andWhere('companies.id=:cid and users.id!=:uid',[ ':uid' => Auction::$app->user->id, ':cid' => Auction::company() ]); return $dataProvider; }