. */ declare(strict_types=1); namespace FireflyIII\Handlers\Events; use FireflyIII\Events\WarnUserAboutBill; use FireflyIII\Notifications\User\BillReminder; use FireflyIII\Support\Facades\Preferences; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; use Mail; /** * Class BillEventHandler */ class BillEventHandler { /** * @param WarnUserAboutBill $event * @return void */ public function warnAboutBill(WarnUserAboutBill $event): void { Log::debug(sprintf('Now in %s', __METHOD__)); $bill = $event->bill; $preference = Preferences::getForUser($bill->user, 'notification_bill_reminder', true)->data; if (true === $preference) { Log::debug('Bill reminder is true!'); Notification::send($bill->user, new BillReminder($bill, $event->field, $event->diff)); } if (false === $preference) { Log::debug('User has disabled bill reminders.'); } } }