/** * Save data to database */ public function make() { $this->_record->name = $this->name; $this->_record->email = $this->email; $this->_record->message = $this->message; $this->_record->save(); }
/** * Add new row to database and set post is unreaded */ public function make() { // update readed marker $this->_post->readed = 0; $this->_post->save(); // add new answer row in database $record = new FeedbackAnswer(); $record->feedback_id = $this->_post->id; $record->name = $this->name; $record->email = $this->email; $record->message = $this->message; if ($this->_userId > 0) { $record->user_id = $this->_userId; } $record->ip = $this->_ip; $record->save(); // add notification msg $targetId = $this->_post->user_id; if ($targetId !== null && (int) $targetId > 0 && $targetId !== $this->_userId) { $notify = new EntityAddNotification($targetId); $uri = '/feedback/read/' . $this->_post->id . '/' . $this->_post->hash . '#feedback-answer-' . $record->id; $notify->add($uri, EntityAddNotification::MSG_ADD_FEEDBACKANSWER, ['snippet' => Text::snippet($this->message, 50), 'post' => Text::snippet($this->_post->message, 50)]); } }
/** * Process submit new request * @return FeedbackPost */ public function make() { // calculate security hash to direct-on access $hash = Str::randomLatinNumeric(mt_rand(16, 64)); // init new row and set row data $record = new FeedbackPost(); $record->name = $this->name; $record->email = $this->email; $record->message = $this->message; $record->hash = $hash; if (App::$User->isAuth()) { $record->user_id = App::$User->identity()->getId(); } $record->ip = App::$Request->getClientIp(); // save row to db $record->save(); // send notification to email $this->sendEmail($record); return $record; }