1 | <?php |
||
2 | |||
3 | namespace App\Traits; |
||
4 | |||
5 | use App\Mail\PendingAttendanceReminder; |
||
6 | use App\Models\Period; |
||
7 | use App\Models\Teacher; |
||
8 | use Carbon\Carbon; |
||
9 | use Illuminate\Support\Facades\Mail; |
||
10 | |||
11 | trait HandlesAttendance |
||
12 | { |
||
13 | /** Send email reminders to all teachers who have classes with incomplete attendance records */ |
||
14 | public function remindPendingAttendance() |
||
15 | { |
||
16 | $period = Period::get_default_period(); |
||
17 | foreach (Teacher::all() as $teacher) { |
||
18 | $events = $teacher->events_with_pending_attendance($period) |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
19 | ->where('start', '<', (Carbon::parse('24 hours ago'))->toDateTimeString()); |
||
20 | |||
21 | if ($events->count() > 0) { |
||
22 | Mail::to($teacher->email) |
||
23 | ->locale('fr') |
||
24 | ->queue(new PendingAttendanceReminder($teacher, $events)); |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 | } |
||
29 |