/** * Log the email into the database before sending it * * @param array $data * * $data['from'] * $data['to'] * $data['message'] * $data['attachment'] * $data['status'] * $data['user_id'] * $data['type'] * * $data['subject'] * $data['view'] * $data['mailData'] * * @return static */ public function log(array $data) { $this->sendMail($data); return $this->model->create(['from' => $data['from'], 'to' => $data['to'], 'message' => $data['message'], 'attachment' => $data['attachment'], 'status' => $data['status'], 'user_id' => Auth::user()->id, 'type' => $data['type'], 'subject' => $data['subject']]); }