Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

monicahq/monica

23656 stars
2 code files
View monicahq/monica on GitHub

app/Notifications/UserReminded.php

Open in GitHub
use App\Models\Contact\Contact;
use App\Interfaces\MailNotification;
use Illuminate\Notifications\Notification as LaravelNotification;
 
class UserReminded extends LaravelNotification implements MailNotification
{
//
public function via()
{
return ['mail'];
}
 
public function toMail(User $user): MailMessage
{
$contact = Contact::where('account_id', $user->account_id)
->findOrFail($this->reminder->contact_id);
 
$message = (new MailMessage)
->subject(trans('mail.subject_line', ['contact' => $contact->name]))
->greeting(trans('mail.greetings', ['username' => $user->first_name]))
->line(trans('mail.want_reminded_of', ['reason' => $this->reminder->title]))
->line(trans('mail.for', ['name' => $contact->name]))
->action(trans('mail.footer_contact_info2', ['name' => $contact->name]), $contact->getLink());
 
if (! is_null($this->reminder->description)) {
$message = $message
->line(trans('mail.comment', ['comment' => $this->reminder->description]));
}
 
return $message;
}
}

app/Jobs/Reminder/NotifyUserAboutReminder.php

Open in GitHub
use App\Notifications\UserNotified;
use App\Notifications\UserReminded;
 
class NotifyUserAboutReminder
{
//
private function getMessage(): ?MailNotification
{
switch ($this->reminderOutbox->nature) {
case 'reminder':
return new UserReminded($this->reminderOutbox->reminder);
case 'notification':
return new UserNotified($this->reminderOutbox->reminder, $this->reminderOutbox->notification_number_days_before);
default:
return null;
}
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.