To your model Student you can add custom accessor with ValueObject
https://laravel.com/docs/7.x/eloquent-mutators#defining-an-accessor
ValueObject it's like your service class.
https://laracasts.com/series/whip-monstrous-code-into-shape/episodes/6
public function getAttendanceAttribute()
{
return new AttendanceValueObject($this->yourRelationship);
}
Inside AttendanceValueObject you will have your logic to calculate an attendance.
Ten you can call it like
$student = Student::first();
$student->attendance->calculate(); // or whatever you want to have there