Skip to content

Instantly share code, notes, and snippets.

@hotmeteor
Created February 17, 2018 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotmeteor/565909f440161747362e601d7f623a56 to your computer and use it in GitHub Desktop.
Save hotmeteor/565909f440161747362e601d7f623a56 to your computer and use it in GitHub Desktop.
Handling delayed notifications in Laravel, pt. 1
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use Illuminate\Queue\SerializesModels;
class AppointmentReminder extends Notification implements ShouldQueue
{
use Queueable, SerializesModels;
public $appointment;
public function __construct(Appointment $appointment)
{
$this->appointment = $appointment;
$this->delay($appointment->start_date_time)->subDay(1);
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail()
{
// Return mail contents
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment