Pass week to WeeklyReport mail
MODIFY
app/Jobs/SendWeeklyReports.php
app/Jobs/SendWeeklyReports.php
@@ -20,6 +20,7 @@ class SendWeeklyReports implements ShouldQueue {
public function handle() {
$spaces = Space::all();
+ $week = date('W');
foreach ($spaces as $space) {
// TODO CALCULATE STATISTICS
@@ -27,7 +28,7 @@ class SendWeeklyReports implements ShouldQueue {
foreach ($space->users as $user) {
// Only send if user wants to receive report
if ($user->weekly_report) {
- Mail::to($user->email)->queue(new WeeklyReport($space));
+ Mail::to($user->email)->queue(new WeeklyReport($space, $week));
}
}
}

MODIFY
app/Mail/WeeklyReport.php
app/Mail/WeeklyReport.php
@@ -12,15 +12,18 @@ class WeeklyReport extends Mailable {
use Queueable, SerializesModels;
protected $space;
+ protected $week;
- public function __construct(Space $space) {
+ public function __construct(Space $space, $week) {
$this->space = $space;
+ $this->week = $week;
}
public function build() {
return $this->view('emails.weekly_report')
->with([
- 'space' => $this->space
+ 'space' => $this->space,
+ 'week' => $this->week
]);
}
}

MODIFY
resources/views/emails/weekly_report.blade.php
resources/views/emails/weekly_report.blade.php
Here's your weekly report for {{ $space->name }}.
-This week (WEEK_START - WEEK_END) you've
+This week (#{{ $week }}) you've
* Spent CURRENCY SPENT_TOTAL_AMOUNT
* Most of which you've spent on SPENT_MOST_TAG_NAME (CURRENCY SPENT_MOST_TAG_AMOUNT)

Pass week to WeeklyReport mail