update controllers logic

This commit is contained in:
root
2026-04-23 00:04:35 -04:00
parent 1977a513df
commit ca4ba272fc
353 changed files with 13402 additions and 1301 deletions
+19 -1
View File
@@ -3,6 +3,8 @@
namespace App\Policies;
use App\Models\ClassProgressReport;
use App\Models\Configuration;
use App\Models\TeacherClass;
use App\Models\User;
class ClassProgressReportPolicy
@@ -34,7 +36,23 @@ class ClassProgressReportPolicy
private function owns(User $user, ClassProgressReport $report): bool
{
return (int) $report->teacher_id === (int) $user->id;
if ((int) $report->teacher_id === (int) $user->id) {
return true;
}
$schoolYear = (string) (Configuration::getConfig('school_year') ?? '');
if ($schoolYear === '') {
return false;
}
$semester = (string) (Configuration::getConfig('semester') ?? '');
foreach (TeacherClass::assignedForSectionTerm((int) $report->class_section_id, $semester, $schoolYear) as $row) {
if ((int) ($row['teacher_id'] ?? 0) === (int) $user->id) {
return true;
}
}
return false;
}
private function isAdmin(User $user): bool