Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

academico-sis/academico

338 stars
2 code files
View academico-sis/academico on GitHub

app/Mail/AbsenceNotification.php

Open in GitHub
use App\Models\Enrollment;
use App\Models\Event;
use App\Models\Student;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
 
class AbsenceNotification extends Mailable
{
use Queueable;
use SerializesModels;
public $enrollment;
 
public function __construct(public Event $event, public User $student)
{
$nstudent = Student::where('id', $student->id)->first();
$this->enrollment = Enrollment::where('student_id', $nstudent->id)->where('course_id', $event->course_id)->first();
}
 
public function build()
{
return $this
->subject(__('Absence Notification'))
->view('emails.absence_notification');
}
}

app/Jobs/WatchAttendance.php

Open in GitHub
use App\Mail\AbsenceNotification;
use App\Models\Attendance;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
 
class WatchAttendance implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public $tries = 5;
 
public function __construct(protected Attendance $attendance)
{
}
 
public function handle()
{
if ($this->attendance->attendance_type_id == 4) {
$student = $this->attendance->student;
 
$otherRecipients = [];
 
if ($this->attendance->event->teacher->email !== null) {
array_push($otherRecipients, ['email' => $this->attendance->event->teacher->email]);
}
 
if (config('settings.manager_email') !== null) {
array_push($otherRecipients, ['email' => explode(',', config('settings.manager_email'))]);
}
 
foreach ($this->attendance->student->contacts as $contact) {
array_push($otherRecipients, ['email' => $contact->email]);
}
 
Mail::to($student->user->email)
->locale($student->user->locale)
->cc($otherRecipients)
->queue(new AbsenceNotification($this->attendance->event, $student->user));
}
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.