public function actionView($id) { $model = Companies::find()->with([ 'dealerCompanies' => function ($query) use ($id){ $query->joinWith([ 'dealerCompanyPreferences' => function ($query) { $query->joinWith([ 'brand0', 'category0' ]); } ])->where([ 'dealer_company.company' => $id, 'dealer_company.dealer' => Auction::dealer() ]); } ])->where([ 'id' => $id ])->one(); if($model === null){ Auction::error('There is no Company with Company Id '.$id); throw new HttpException(404, 'No Company Found'); } return $this->render('view', [ 'model' => $model, ]); }
public static function MessageTemplate($name){ $message = MessageTemplate::find('name=:name',[':name' => $name])->one(); if($message){ return $message->template; }else{ Auction::error('There is no '. $name .' in database create it admin'); throw new HttpException(400 ,'No '. $name .' Found Create it'); } }
protected function loadProfile(){ $model = Dealers::find()->joinWith([ 'user0', 'dealerPreferences' => function($query){ $query->with([ 'category0', 'brand0' ]); } ])->where([ 'dealers.id' => Auction::$app->session->get('user.dealer', 0) ])->one(); if($model === null){ Auction::error('No Valid Dealer Found with userid '.Auction::$app->user->id); throw new HttpException(404, 'No user found'); } return $model; }
public function afterSave(){ $_model = new AuctionEmails(); $_model->message = strtr(MessageTemplate::MessageTemplate(DatabaseHelper::DEALER_REGISTRATION_TEMPLATE),['{name}' => $this->name]); $_model->to = $this->email; $_model->subject = 'Auction :: Company Registration'; $_model->from = 'Auction'; $_model->status = DatabaseHelper::SEND_MAIL; if($_model->save()){ Auction::info('Company Registration Email registered'); } else { $message= Auction::loggerMessageFormat('Email is not send to user due to following errors',$_model->getErrors()); Auction::error($message); } }
public function saveLot($request){ $this->load($request); $transaction = Auction::$app->db->beginTransaction(); try{ if(!$this->save()) return false; $preferences= new LotPreference(); $preferences->load($request); $preferences->lots = $this->primaryKey; if($preferences->save()){ $transaction->commit(); return true; } return false; }catch(Exception $ex){ Auction::error('Lot Not Saved Due to following Errors'.$ex->getMessage()); $transaction->rollBack(); return false; } }
/** Send Reset Token */ public static function SendResetToken($event){ $message = ''; switch ($event->sender->mode){ case DatabaseHelper::TOKEN_SEND_MODE_WEB: $message = MessageTemplate::MessageTemplate(DatabaseHelper::FORGOT_PASSWORD_MAIL_TEMPLATE); $_model = new AuctionEmails(); $_model->to = $event->sender->userObject->email; $_model->subject = 'Auction :: Reset Password Email'; $_model->status = 0 ; $_model->from = 'Auction'; break; case DatabaseHelper::TOKEN_SEND_MODE_MOBILE: $message = MessageTemplate::MessageTemplate(DatabaseHelper::FORGOT_PASSWORD_SMS_TEMPLATE); $_model = new OptHistory(); $_model->mobile = $event->sender->userObject->mobile; break; } if($message == ''){ Auction::error('No Valid Msg Template Found For ' .$event->sender->mode.' in database'); throw new HttpException(400 , 'No Template Found'); } $_model->message = $message; if($_model->save()){ Auction::info('User Token successfully Created'); }else { $_message = Auction::loggerMessageFormat('User reset token template invalid ',$_model->getErrors()); Auction::error($_message); } }