diff --git a/app/Mail/Digest.php b/app/Mail/Digest.php index 9d04259..4379ee4 100644 --- a/app/Mail/Digest.php +++ b/app/Mail/Digest.php @@ -24,17 +24,24 @@ class Digest extends Mailable /** * The current trip locations as a JSON object. * - * @var string + * @var obj */ public $locations; /** * The current trip checkins as a JSON object. * - * @var string + * @var obj */ public $checkinsList; + /** + * The current trip object. + * + * @var obj + */ + public $trip; + /** * Create a new message instance. * @@ -45,7 +52,7 @@ class Digest extends Mailable public function __construct(string $digest_type, string $trip_id) { $this->digest_type = $digest_type; - $trip = (new TrackerController)->get_trip_data($trip_id); + $this->trip = (new TrackerController)->get_trip_data($trip_id); $cutoffDateTime = new DateTime(); switch ($this->digest_type) { @@ -65,7 +72,7 @@ class Digest extends Mailable } $this->checkinsList = array_filter( - $trip->checkins, + $this->trip->checkins, function ($elem) use ($cutoffDateTime) { $elemDateTime = new DateTime($elem->created_at); return $elemDateTime > $cutoffDateTime; @@ -80,7 +87,11 @@ class Digest extends Mailable */ public function build() { - return $this->view('emails.digest') - ->subject("track.bengoldsworthy.net ".ucwords($this->digest_type)." Digest"); + return $this->view( + 'emails.digest', + [ + 'trip' => $this->trip + ] + )->subject("track.bengoldsworthy.net ".ucwords($this->digest_type)." Digest"); } }