28 lines
805 B
PHP
28 lines
805 B
PHP
<?php
|
|
|
|
namespace App\Services\Parents;
|
|
|
|
use CodeIgniter\Database\BaseConnection;
|
|
|
|
class ParentAttendanceService
|
|
{
|
|
public function __construct(private readonly BaseConnection $db)
|
|
{
|
|
}
|
|
|
|
public function attendanceForParent(int $parentId, string $schoolYear): array
|
|
{
|
|
if ($parentId <= 0 || $schoolYear === '') {
|
|
return [];
|
|
}
|
|
|
|
return $this->db->table('attendance_data')
|
|
->select('students.firstname, students.lastname, attendance_data.date, attendance_data.status, attendance_data.reason')
|
|
->join('students', 'students.id = attendance_data.student_id')
|
|
->where('attendance_data.school_year', $schoolYear)
|
|
->where('students.parent_id', $parentId)
|
|
->get()
|
|
->getResultArray();
|
|
}
|
|
}
|