public function searchCompanyDealer(){ $query = DealerCompany::find()->joinWith([ 'dealer0', ])->where([ 'dealer_company.company' => Auction::$app->session->get('user.company'), // 'dealer_company.is_active' => DatabaseHelper::ACTIVE ]); return new ActiveDataProvider([ 'query' => $query, ]); }
/** * Company Added By Dealer * then status => 1 * * is_active need to change by company/company User */ public function addedByDealer($id){ $_model = DealerCompany::find()->where([ 'company' => $id, 'dealer' => Auction::dealer() ])->one(); if($_model === null){ $_model = new DealerCompany(); $_model->company = $id; $_model->dealer = Auction::dealer(); $_model->is_active = DatabaseHelper::IN_ACTIVE; $_model->status = DatabaseHelper::ACTIVE; $_model->mode = DatabaseHelper::DEALER_APPROVE_APPROVAL_REQUIRED; Auction::infoLog('Creating A new Dealer Company Since No Record of DealerCompany of',['company' => $id ,'dealer' => Auction::dealer()]); }else{ switch ($_model->status){ case DatabaseHelper::ACTIVE : $_model->status = DatabaseHelper::IN_ACTIVE; break; case DatabaseHelper::IN_ACTIVE : $_model->status = DatabaseHelper::ACTIVE; break; } Auction::infoLog('Updating Dealer Company Status',['company' => $id ,'dealer' => Auction::dealer()]); } return $_model->save(); }