@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\SchoolYear;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class SchoolYearTableRegistry
|
||||
{
|
||||
public const YEAR_SCOPED = [
|
||||
'additional_charges',
|
||||
'archived_paypal_transactions',
|
||||
'attendance_data',
|
||||
'attendance_day',
|
||||
'attendance_record',
|
||||
'attendance_tracking',
|
||||
'badge_print_logs',
|
||||
'below_sixty_decisions',
|
||||
'calendar_events',
|
||||
'certificate_records',
|
||||
'classSection',
|
||||
'class_progress_reports',
|
||||
'competitions',
|
||||
'current_flag',
|
||||
'discount_vouchers',
|
||||
'early_dismissal_signatures',
|
||||
'enrollments',
|
||||
'events',
|
||||
'exams',
|
||||
'exam_drafts',
|
||||
'expenses',
|
||||
'final_exam',
|
||||
'final_score',
|
||||
'flag',
|
||||
'grading_locks',
|
||||
'homework',
|
||||
'inventory_movements',
|
||||
'invoices',
|
||||
'late_slip_logs',
|
||||
'manual_payments',
|
||||
'midterm_exam',
|
||||
'missing_score_overrides',
|
||||
'parent_attendance_reports',
|
||||
'parent_meeting_schedules',
|
||||
'parent_notifications',
|
||||
'participation',
|
||||
'payments',
|
||||
'payment_transactions',
|
||||
'placement_batches',
|
||||
'print_requests',
|
||||
'project',
|
||||
'quiz',
|
||||
'refunds',
|
||||
'reimbursements',
|
||||
'reimbursement_batches',
|
||||
'report_card_acknowledgements',
|
||||
'scan_log',
|
||||
'score_comments',
|
||||
'semester_scores',
|
||||
'staff_attendance',
|
||||
'student_class',
|
||||
'student_decisions',
|
||||
'teacher_attendance_data',
|
||||
'teacher_class',
|
||||
'teacher_submission_notification_history',
|
||||
'whatsapp_group_links',
|
||||
'whatsapp_group_memberships',
|
||||
];
|
||||
|
||||
public const GLOBAL = [
|
||||
'authorized_users',
|
||||
'cache',
|
||||
'cache_locks',
|
||||
'configuration',
|
||||
'email_templates',
|
||||
'ip_attempts',
|
||||
'login_activity',
|
||||
'migrations',
|
||||
'nav_items',
|
||||
'parent_accounts',
|
||||
'password_reset_requests',
|
||||
'password_resets',
|
||||
'permissions',
|
||||
'personal_access_tokens',
|
||||
'preferences',
|
||||
'role_nav_items',
|
||||
'role_permissions',
|
||||
'roles',
|
||||
'school_years',
|
||||
'sessions',
|
||||
'settings',
|
||||
'user_preferences',
|
||||
'user_roles',
|
||||
'users',
|
||||
];
|
||||
|
||||
public const IDENTITY_WITH_YEAR_RELATION = [
|
||||
'emergency_contacts',
|
||||
'families',
|
||||
'family_guardians',
|
||||
'family_students',
|
||||
'parents',
|
||||
'staff',
|
||||
'student_allergies',
|
||||
'student_medical_conditions',
|
||||
'students',
|
||||
'teachers',
|
||||
];
|
||||
|
||||
public const CONTEXT = [
|
||||
'audit_logs',
|
||||
'communication_logs',
|
||||
'contactus',
|
||||
'finance_notification_logs',
|
||||
'messages',
|
||||
'notification_recipients',
|
||||
'notifications',
|
||||
'payment_notification_logs',
|
||||
'support_requests',
|
||||
'user_notifications',
|
||||
];
|
||||
|
||||
public static function isYearScoped(string $table): bool
|
||||
{
|
||||
return in_array($table, self::YEAR_SCOPED, true);
|
||||
}
|
||||
|
||||
public static function isGlobal(string $table): bool
|
||||
{
|
||||
return in_array($table, self::GLOBAL, true);
|
||||
}
|
||||
|
||||
public static function isIdentityWithYearRelation(string $table): bool
|
||||
{
|
||||
return in_array($table, self::IDENTITY_WITH_YEAR_RELATION, true);
|
||||
}
|
||||
|
||||
public static function isContext(string $table): bool
|
||||
{
|
||||
return in_array($table, self::CONTEXT, true);
|
||||
}
|
||||
|
||||
public static function categoryOf(string $table): string
|
||||
{
|
||||
return match (true) {
|
||||
self::isYearScoped($table) => 'YEAR_SCOPED',
|
||||
self::isGlobal($table) => 'GLOBAL',
|
||||
self::isIdentityWithYearRelation($table) => 'IDENTITY_WITH_YEAR_RELATION',
|
||||
self::isContext($table) => 'CONTEXT',
|
||||
default => throw new InvalidArgumentException(
|
||||
"Table '{$table}' is not registered for school-year behavior."
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user