From 33f9a8584d83baeb1737928fef6bb69fc793fb4c Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Mon, 28 Nov 2022 13:49:14 -0600 Subject: [PATCH] Replace checkins list with partial in email template --- app/Mail/Digest.php | 6 +++--- resources/views/emails/digest.blade.php | 19 ++----------------- resources/views/tracker.blade.php | 3 +-- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/app/Mail/Digest.php b/app/Mail/Digest.php index bfaf608..ccf0ba3 100644 --- a/app/Mail/Digest.php +++ b/app/Mail/Digest.php @@ -33,7 +33,7 @@ class Digest extends Mailable * * @var string */ - public $checkins; + public $checkinsList; /** * Create a new message instance. @@ -72,8 +72,8 @@ class Digest extends Mailable } ); - $this->checkins = array_filter( - $trip->checkins, + $this->checkinsList = array_filter( + $trip->checkinsList, function($elem) use ($cutoffDateTime) { $elemDateTime = new DateTime($elem->created_at); return $elemDateTime > $cutoffDateTime; diff --git a/resources/views/emails/digest.blade.php b/resources/views/emails/digest.blade.php index 166f215..d220ca5 100644 --- a/resources/views/emails/digest.blade.php +++ b/resources/views/emails/digest.blade.php @@ -37,24 +37,9 @@

View the tracker here.


Checkins

-@if($checkins) +@if($checkinsList)
    - @foreach($checkins as $checkin) -
  1. -
    - -

    {!! $checkin->title ?? "Untitled" !!}

    -

    {!! render_date_difference($checkin->date) !!}

    -
    - @if($checkin->note) - {!! $checkin->note !!} - @endif - @if($checkin->image_url) - - @endif -
    -
  2. - @endforeach + @include('partials.checkins-list')
@else

No new checkins

diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index b956e7d..8c9bdd1 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -38,8 +38,7 @@ @php $checkinsList = array_slice(array_reverse($trip->checkins), 0, 10) @endphp @endif - @include('partials.checkin-list') - + @include('partials.checkins-list') @if (!$showAllCheckins)

Show all checkins