From 98dc469772fb7f6762aeb2351213cd515c070b76 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Sun, 9 Jun 2024 22:29:04 +0200 Subject: [PATCH] fix: pass `` to email --- app/Mail/Digest.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) 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"); } }