| Conditions | 5 |
| Paths | 9 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function handle() |
||
| 33 | { |
||
| 34 | if ($this->attendance->attendance_type_id == 4) { |
||
| 35 | // if so, send an email |
||
| 36 | $student = $this->attendance->student; |
||
| 37 | |||
| 38 | // CC to the teacher and the administration |
||
| 39 | $otherRecipients = []; |
||
| 40 | |||
| 41 | if ($this->attendance->event->teacher->email !== null) { |
||
| 42 | array_push($otherRecipients, ['email' => $this->attendance->event->teacher->email]); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (config('settings.manager_email') !== null) { |
||
| 46 | array_push($otherRecipients, ['email' => explode(',', config('settings.manager_email'))]); |
||
| 47 | } |
||
| 48 | |||
| 49 | // also send to the student's contacts |
||
| 50 | foreach ($this->attendance->student->contacts as $contact) { |
||
| 51 | array_push($otherRecipients, ['email' => $contact->email]); |
||
| 52 | } |
||
| 53 | |||
| 54 | Mail::to($student->user->email) |
||
| 55 | ->locale($student->user->locale) |
||
| 56 | ->cc($otherRecipients) |
||
| 57 | ->queue(new AbsenceNotification($this->attendance->event, $student->user)); |
||
| 58 | } |
||
| 61 |