Issues (350)

app/Traits/HandlesAttendance.php (1 issue)

Labels
Severity
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
It seems like $period can also be of type null; however, parameter $period of App\Models\Teacher::even...th_pending_attendance() does only seem to accept App\Models\Period, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
            $events = $teacher->events_with_pending_attendance(/** @scrutinizer ignore-type */ $period)
Loading history...
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