. */ declare(strict_types=1); namespace FireflyIII\Handlers\Events; use Exception; use FireflyIII\Events\RequestedReportOnJournals; use FireflyIII\Mail\ReportNewJournalsMail; use FireflyIII\Repositories\User\UserRepositoryInterface; use Log; use Mail; /** * Class AutomationHandler */ class AutomationHandler { /** * @param RequestedReportOnJournals $event * * @return bool */ public function reportJournals(RequestedReportOnJournals $event): bool { Log::debug('In reportJournals.'); /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); $user = $repository->findNull($event->userId); if (null === $user) { Log::debug('User is NULL'); return true; } if ($event->journals->count() === 0) { Log::debug('No journals.'); return true; } try { Log::debug('Trying to mail...'); Mail::to($user->email)->send(new ReportNewJournalsMail($user->email, '127.0.0.1', $event->journals)); // @codeCoverageIgnoreStart } catch (Exception $e) { Log::error($e->getMessage()); } Log::debug('Done!'); // @codeCoverageIgnoreEnd return true; } }