/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MessageTemplate::find(); $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([ 'id' => $this->id, 'type' => $this->type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'is_active' => $this->is_active, ]); $query->andFilterWhere(['like', 'name', $this->name]) ->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
/** * Finds the MessageTemplate model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MessageTemplate the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MessageTemplate::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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'); } }
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 :: Dealer Registration'; $_model->from = 'Auction'; $_model->status = DatabaseHelper::SEND_MAIL; if($_model->save()){ Auction::info('Dealer Registration Email registered'); } else { $message= Auction::loggerMessageFormat('Email is not send to user due to following errors',$_model->getErrors()); Auction::error($message); } }
/** 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); } }