/** * Handle the event. * * @param EmailAddedToQueue $event * @return void */ public function handle(EmailAddedToQueue $event) { // retrieve the data from the event object $data = $event->getMail(); $response = $event->getResponse(); $tags = $data->getTags(); if (count($tags) > 1) { $tags = json_encode($tags); } else { $tags = reset($tags); } $l = MailStatistic::create(['recipient' => $data->getTo()->getEmail(), 'tag' => $tags, 'status' => 'queued', 'project_id' => $data->getProject()->id, 'service_message_id' => $response->http_response_body->id, 'category_id' => $data->getCategory() ? $data->getCategory()->id : null]); }
/** * Create the log entry with the provided information * * @return MailStatistic */ public function log() { $log = MailStatistic::create(['recipient' => $this->recipient, 'tag' => $this->tag, 'status' => $this->status, 'project_id' => $this->project->id, 'service_message_id' => $this->service_id, 'category_id' => !$this->category ? null : $this->category->id]); return $log; }
/** @test */ public function mailstat_create_without_a_given_category_should_not_throw_exception() { $statistic = $this->mailStatistics->create(['recipient' => "*****@*****.**", 'tag' => 'tag', 'status' => 'queued', 'project_id' => $this->project->id, 'service_message_id' => "insertmessageidhere"]); $this->assertInstanceOf($this->mailStatisticsClass, $statistic); $this->assertNull($statistic->category); }