/** * Finds the SendLog model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SendLog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SendLog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { if (isset($params['mail_id'])) { $this->mail_id = $params['mail_id']; } $query = SendLog::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $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(['id' => $this->id, 'user_id' => $this->user_id, 'mail_id' => $this->mail_id, 'send_time' => $this->send_time, 'success' => $this->success]); return $dataProvider; }
private function saveResult($mail_id, $user_id, $result) { $model = new SendLog(); $model->user_id = $user_id; $model->mail_id = $mail_id; $model->success = $result; $model->save(); }