remove codeigniter

This commit is contained in:
root
2026-06-04 02:41:08 -04:00
parent 4e33882ac7
commit b4e6ac03c5
180 changed files with 457 additions and 2186 deletions
@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* Administrative competition-winner workflows (ported from CodeIgniter {@see \App\Controllers\Admin\CompetitionWinnersController}).
* Administrative competition-winner workflows (ported from legacy {@see \App\Controllers\Admin\CompetitionWinnersController}).
*/
class CompetitionWinnersAdminService
{
@@ -627,7 +627,7 @@ class CompetitionWinnersAdminService
}
/**
* Export competition scores into quiz rows (SQL preserved from CodeIgniter).
* Export competition scores into quiz rows (SQL preserved from legacy).
*
* @return array{ok: bool, message: string, quizIndexes?: array<int,int>}
*/
@@ -2,7 +2,7 @@
namespace App\Services\Admin\CompetitionWinners;
/** Pure domain logic ported from CodeIgniter `Admin\CompetitionWinnersController` (private helpers). */
/** Pure domain logic ported from legacy `Admin\CompetitionWinnersController` (private helpers). */
final class CompetitionWinnersDomain
{
/** @var array<int, array{min:int, max:?int, winners:int}> */
@@ -22,7 +22,7 @@ class StaffAttendanceService
) {}
/**
* CodeIgniter {@see \App\Controllers\View\AttendanceController::index} — single date / section teacher grid JSON.
* legacy {@see \App\Controllers\View\AttendanceController::index} — single date / section teacher grid JSON.
*/
public function teacherAttendanceDayIndex(?string $semester, ?string $schoolYear, string $dateYmd, int $sectionCode): array
{
@@ -107,7 +107,7 @@ class StaffAttendanceService
}
/**
* Bulk save for CI {@see \App\Controllers\View\AttendanceController::save} (method missing in CI; implemented here).
* Bulk save for legacy {@see \App\Controllers\View\AttendanceController::save} (method missing in legacy; implemented here).
*/
public function saveTeacherAttendanceBulk(Authenticatable $user, array $payload): array
{
@@ -75,7 +75,7 @@ class AttendanceTrackingService
}
/**
* CodeIgniter POST attendance/send-auto-emails — runs auto_email actions on current pending violations.
* legacy POST attendance/send-auto-emails — runs auto_email actions on current pending violations.
*/
public function sendAutoEmails(mixed $variantInput): array
{
@@ -121,7 +121,7 @@ class AttendanceTrackingService
}
/**
* CodeIgniter route referenced {@see View\AttendanceTrackingController::notify_parent} was never implemented in CI;
* legacy route referenced {@see View\AttendanceTrackingController::notify_parent} was never implemented in legacy;
* this matches the attendance notification modal (student_id, to, subject, message, subject_type, date).
*/
public function notifyParent(array $input): array
@@ -11,8 +11,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
/**
* Mirrors CodeIgniter `AuthController::apiLogin` security behavior:
* IP lockout (ip_attempts), failed_attempts / suspension after 3 failures, login_activity logging.
* Centralizes API login lockout, suspension, and audit logging behavior.
*/
class ApiLoginSecurityService
{
@@ -79,7 +78,7 @@ class ApiLoginSecurityService
if ($failedAttempts >= 3) {
$data['is_suspended'] = true;
// CI sends reset email via View\UserController::sendResetEmail — wire Laravel mail here when parity is needed.
// Password-reset delivery can be wired here when the suspension workflow is finalized.
Log::notice('api_login: account suspended after failed attempts', ['email' => $email, 'user_id' => $user->id]);
}
@@ -113,7 +112,7 @@ class ApiLoginSecurityService
}
/**
* CI returns roles as an object map {"RoleName": true}.
* Returns roles as an object map {"RoleName": true}.
*
* @param list<string> $roleNames
*/
@@ -128,13 +127,13 @@ class ApiLoginSecurityService
}
/**
* Top-level JSON body aligned with the CodeIgniter 4 `AuthController::apiLogin` success payload.
* Top-level JSON body for API login success responses.
*
* @return array{status: true, token: string, user: array{id: int, name: string, roles: object, class_section_id: ?int, class_section_name: ?string}}
*/
public function buildLoginResponse(User $user, string $jwtToken): array
{
$roleNames = $user->roleNamesLikeCodeIgniter();
$roleNames = $user->roleNames();
$fullName = trim(($user->firstname ?? '').' '.($user->lastname ?? ''));
$teacherContext = $user->teacherSessionContext();
@@ -9,13 +9,14 @@ use App\Models\UserRole;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth;
/**
* Matches CodeIgniter 4 `AuthController::apiRegister` (public API register, no captcha).
* Handles direct public API registration requests that bypass the captcha flow.
*/
class CodeIgniterApiRegistrationService
class ApiRegistrationService
{
public function registerResponse(Request $request): JsonResponse
{
@@ -115,7 +116,7 @@ class CodeIgniterApiRegistrationService
],
], 201);
} catch (\Throwable $e) {
log_message('error', 'Registration error: '.$e->getMessage());
Log::error('Registration error: '.$e->getMessage());
return response()->json([
'status' => false,
+8 -8
View File
@@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
/**
* CodeIgniter `AuthController` web (session) flow: session keys, dashboards, redirects, preferences.
* Session-auth flow: session keys, dashboards, redirects, and preferences.
*/
class AuthSessionService
{
@@ -25,7 +25,7 @@ class AuthSessionService
}
/**
* Same-host relative redirect sanitization as CI `sanitizeRedirectTarget`.
* Sanitizes login redirects to same-host relative paths only.
*/
public function sanitizeRedirectTarget(string $redirectTo): ?string
{
@@ -84,7 +84,7 @@ class AuthSessionService
}
/**
* Apply CI-style preference keys into session (style/menu colors).
* Apply stored style preferences into the session.
*/
public function applyStylePreferencesToSession(int $userId): void
{
@@ -114,11 +114,11 @@ class AuthSessionService
}
/**
* Populate Laravel web auth + CI-compatible session keys.
* Populate Laravel web auth and session state for the web portal.
*
* @param list<string> $roleNames
*/
public function writeCiAuthenticatedSession(User $user, array $roleNames): void
public function writeAuthenticatedSession(User $user, array $roleNames): void
{
Auth::guard('web')->login($user);
@@ -145,7 +145,7 @@ class AuthSessionService
}
/**
* Close open login_activity row(s) without logout_time for this user (CI parity).
* Close open login_activity rows without logout_time for this user.
*/
public function logLogout(?int $userId, ?string $email): void
{
@@ -169,7 +169,7 @@ class AuthSessionService
*/
public function resolvePostLoginDestination(User $user, ?string $sanitizedRedirect): array
{
$roleNames = $user->roleNamesLikeCodeIgniter();
$roleNames = $user->roleNames();
if ($roleNames === []) {
Log::notice('session_login: user has no roles', ['user_id' => $user->id]);
@@ -180,7 +180,7 @@ class AuthSessionService
];
}
$this->writeCiAuthenticatedSession($user, $roleNames);
$this->writeAuthenticatedSession($user, $roleNames);
if (count($roleNames) === 1) {
session()->put('role', $roleNames[0]);
+2 -2
View File
@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* CodeIgniter {@see \App\Controllers\View\RFIDController} parity (badge scan + log listing).
* legacy {@see \App\Controllers\View\RFIDController} parity (badge scan + log listing).
*/
class BadgeScanService
{
@@ -64,7 +64,7 @@ class BadgeScanService
}
/**
* Scan log listing (legacy CI RFIDController::log() query shape).
* Scan log listing (legacy RFIDController::log() query shape).
*
* @return list<array<string, mixed>>
*/
@@ -19,7 +19,7 @@ class ClassProgressMetaService
}
/**
* Fallback: next N Sundays from today (CI `buildUpcomingSundayOptions`).
* Fallback: next N Sundays from today (legacy `buildUpcomingSundayOptions`).
*
* @return list<string>
*/
@@ -29,7 +29,7 @@ class ClassProgressMetaService
}
/**
* CI-aligned Sundays within semester/school-year range when configuration allows.
* legacy-aligned Sundays within semester/school-year range when configuration allows.
*
* @return list<string>
*/
@@ -67,7 +67,7 @@ class ClassProgressMetaService
return $options !== [] ? $options : $this->buildUpcomingSundayOptions($count);
}
/** CI `pickDefaultWeekStart`. */
/** legacy `pickDefaultWeekStart`. */
public function pickDefaultWeekStart(array $options): string
{
if ($options === []) {
@@ -109,7 +109,7 @@ class ClassProgressMetaService
}
/**
* CI `resolveProgressDateRange`.
* legacy `resolveProgressDateRange`.
*
* @return array{0:string,1:string}|null
*/
@@ -110,7 +110,7 @@ class ClassProgressMutationService
}
/**
* CI `ClassProgressController::update` — sync all subjects for the weekly batch keyed by {@see $anchor}.
* legacy `ClassProgressController::update` — sync all subjects for the weekly batch keyed by {@see $anchor}.
*
* @return Collection<int, ClassProgressReport>
*/
@@ -155,7 +155,7 @@ class ClassProgressQueryService
}
/**
* CI `ClassProgressController::resolveAssignedTeacherIds`.
* legacy `ClassProgressController::resolveAssignedTeacherIds`.
*
* @return list<int>
*/
@@ -4,7 +4,7 @@ namespace App\Services\ClassProgress;
class ClassProgressRuleService
{
/** CI `ClassProgressController::CUSTOM_UNIT_ROW_LABEL` — must match teacher form JS. */
/** legacy `ClassProgressController::CUSTOM_UNIT_ROW_LABEL` — must match teacher form JS. */
public const CUSTOM_UNIT_ROW_LABEL = 'Custom';
public function defaultStatus(): string
@@ -19,7 +19,7 @@ class ClassProgressRuleService
}
/**
* CI `buildUnitChapterSummary` — Custom / typed chapter rows preserved.
* legacy `buildUnitChapterSummary` — Custom / typed chapter rows preserved.
*
* @param array<int|string, mixed> $unitValues
* @param array<int|string, mixed> $chapterValues
@@ -56,7 +56,7 @@ class ClassProgressRuleService
return mb_strlen($summary) > 120 ? mb_substr($summary, 0, 120) : $summary;
}
/** CI `hasIslamicUnitSelection`. */
/** legacy `hasIslamicUnitSelection`. */
public function hasIslamicUnitSelection(array $payload): bool
{
$unitValues = array_map('trim', (array) ($payload['unit_islamic'] ?? []));
@@ -92,7 +92,7 @@ class ClassProgressRuleService
}
/**
* CI `parseUnitChapterSummary` — inverse of {@see buildUnitChapterSummary()} for edit forms.
* legacy `parseUnitChapterSummary` — inverse of {@see buildUnitChapterSummary()} for edit forms.
*
* @return array{units: list<string>, chapters: list<string>}
*/
@@ -282,9 +282,7 @@ class DiscountApplyService
$semester
);
if (class_exists(\CodeIgniter\Events\Events::class)) {
\CodeIgniter\Events\Events::trigger('paymentReceived', $eventData, $studentData);
} elseif (function_exists('event')) {
if (function_exists('event')) {
event('paymentReceived', [$eventData, $studentData]);
}
} catch (\Throwable $e) {
+1 -1
View File
@@ -13,7 +13,7 @@ class ApiDocsService
}
/**
* Bootstrap payload for the documentation SPA (replaces CI swagger_ui / swagger_ui_public views).
* Bootstrap payload for the documentation SPA (replaces legacy swagger_ui / swagger_ui_public views).
*
* @return array<string, mixed>
*/
+2 -2
View File
@@ -5,7 +5,7 @@ namespace App\Services\Docs;
use App\Services\ApplicationUrlService;
/**
* CodeIgniter parity: {@see \App\Controllers\DocsController::index} and
* legacy parity: {@see \App\Controllers\DocsController::index} and
* {@see \App\Controllers\View\DocsController::swagger} (multi-spec Swagger UI payload).
*/
class DocsCatalogService
@@ -36,7 +36,7 @@ class DocsCatalogService
}
/**
* Multi-spec dropdown payload (CI `View\DocsController::swagger` / `swagger_ui` view).
* Multi-spec dropdown payload (legacy `View\DocsController::swagger` / `swagger_ui` view).
*
* @return array{specs: list<array{name: string, url: string}>, merged_openapi_url: string}
*/
@@ -208,9 +208,7 @@ class ExtraChargesChargeService
$students = [];
try {
if (class_exists(\CodeIgniter\Events\Events::class)) {
\CodeIgniter\Events\Events::trigger('extraCharge', $eventData, $students);
} elseif (function_exists('event')) {
if (function_exists('event')) {
event('extraCharge', [$eventData, $students]);
}
} catch (\Throwable $e) {
@@ -9,7 +9,7 @@ use App\Services\Email\EmailDispatchService;
use Illuminate\Support\Facades\DB;
/**
* CodeIgniter {@see \App\Controllers\View\AuthorizedUsersController} parity.
* legacy {@see \App\Controllers\View\AuthorizedUsersController} parity.
*/
class AuthorizedUsersManagementService
{
@@ -26,7 +26,7 @@ class AuthorizedUsersManagementService
}
/**
* CI create() first step — lookup by token after invite email (pending row, created within TTL).
* legacy create() first step — lookup by token after invite email (pending row, created within TTL).
*
* Tokens are stored as SHA-256 hashes; we only ever look up by hash so that
* a leaked database row cannot be replayed as a plaintext token.
@@ -44,7 +44,7 @@ class AuthorizedUsersManagementService
}
/**
* CI setPassword / savePassword — active row with rotating token.
* legacy setPassword / savePassword — active row with rotating token.
*/
public function findActiveSetupRow(int $authorizedUserId, string $plainToken): ?AuthorizedUser
{
@@ -83,7 +83,7 @@ class AuthorizedUsersManagementService
}
/**
* CI `create` — when email is not a registered user, respond success without leaking (privacy).
* legacy `create` — when email is not a registered user, respond success without leaking (privacy).
*
* Refuses self-invites and silently re-uses an existing invite row to avoid
* letting a parent spam another user with confirmation emails.
@@ -385,7 +385,7 @@ class ParentAttendanceReportService
/**
* Staff index: early dismissal rows grouped by date (+ signature metadata per date).
*
* Parity with CodeIgniter {@see \App\Controllers\View\ParentAttendanceReportController::earlyDismissals}.
* Parity with legacy {@see \App\Controllers\View\ParentAttendanceReportController::earlyDismissals}.
*
* @return array{groups: array<string, array<int, array<string, mixed>>>, school_year: string, semester: string, signature_by_date: array<string, array<string, mixed>>}
*/
@@ -467,7 +467,7 @@ class ParentAttendanceReportService
}
/**
* Parity with CodeIgniter {@see \App\Controllers\View\ParentAttendanceReportController::addEarlyDismissalForm}.
* Parity with legacy {@see \App\Controllers\View\ParentAttendanceReportController::addEarlyDismissalForm}.
*
* @return array{students: array<int, array<string, mixed>>, default_date: string, school_year: string, semester: string}
*/
@@ -505,7 +505,7 @@ class ParentAttendanceReportService
}
/**
* Parity with CodeIgniter {@see \App\Controllers\View\ParentAttendanceReportController::saveEarlyDismissal}.
* Parity with legacy {@see \App\Controllers\View\ParentAttendanceReportController::saveEarlyDismissal}.
*/
public function saveStaffEarlyDismissal(int $studentId, string $reportDate, string $dismissTime, string $reason): void
{
@@ -573,7 +573,7 @@ class ParentAttendanceReportService
}
/**
* Parity with CodeIgniter {@see \App\Controllers\View\ParentAttendanceReportController::uploadEarlyDismissalSignature}.
* Parity with legacy {@see \App\Controllers\View\ParentAttendanceReportController::uploadEarlyDismissalSignature}.
* Files live under {@see storage_path('uploads/early_dismissal_signatures')} (same as {@see \App\Http\Controllers\Api\Reports\FilesController::earlyDismissalSignature}).
*/
public function storeEarlyDismissalSignature(
@@ -8,7 +8,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
/**
* CodeIgniter {@see \App\Controllers\ParentProgressController} read-side logic.
* legacy {@see \App\Controllers\ParentProgressController} read-side logic.
*/
class ParentProgressQueryService
{
@@ -17,7 +17,7 @@ class ParentProgressQueryService
) {}
/**
* CI `getParentStudents` — one row per distinct student (latest enrollment ordering).
* legacy `getParentStudents` — one row per distinct student (latest enrollment ordering).
*
* @return list<array<string, mixed>>
*/
@@ -59,7 +59,7 @@ class ParentProgressQueryService
}
/**
* CI `getParentSectionIds`.
* legacy `getParentSectionIds`.
*
* @return list<int>
*/
@@ -119,7 +119,7 @@ class ParentProgressQueryService
}
/**
* CI `groupReportsByWeek` — keys `"{week_start}:{class_section_id}"`.
* legacy `groupReportsByWeek` — keys `"{week_start}:{class_section_id}"`.
*
* @param iterable<int, ClassProgressReport> $rows
* @return array<string, array<string, mixed>>
@@ -166,7 +166,7 @@ class ParentProgressQueryService
}
/**
* Weekly batch for a section/week (CI parent `view`, all subjects).
* Weekly batch for a section/week (legacy parent `view`, all subjects).
*
* @return list<ClassProgressReport>
*/
@@ -9,7 +9,7 @@ use App\Models\User;
use Illuminate\Support\Facades\DB;
/**
* CodeIgniter {@see \App\Controllers\ParentReportCardController} parity (read + acknowledgement).
* legacy {@see \App\Controllers\ParentReportCardController} parity (read + acknowledgement).
*/
class ParentReportCardService
{
@@ -19,7 +19,7 @@ class ParentReportCardService
) {}
/**
* Resolve term from query string with configuration fallbacks (CI index/view).
* Resolve term from query string with configuration fallbacks (legacy index/view).
*
* @return array{0: string, 1: string}
*/
@@ -38,7 +38,7 @@ class ParentReportCardService
}
/**
* CI sign() — current configuration term only (no GET overrides).
* legacy sign() — current configuration term only (no GET overrides).
*
* @return array{0: string, 1: string}
*/
@@ -56,7 +56,7 @@ class ParentReportCardService
}
/**
* CI index() student rows for parent + optional student_class term filters.
* legacy index() student rows for parent + optional student_class term filters.
*
* @return list<array<string, mixed>>
*/
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\DB;
/**
* Maps the logged-in parent-family account to the primary parent's user id
* (stored on {@see \App\Models\Student::$parent_id}), matching CodeIgniter
* (stored on {@see \App\Models\Student::$parent_id}), matching legacy
* {@see \App\Controllers\ParentReportCardController::resolvePrimaryParentId}.
*/
final class PrimaryParentUserResolver
@@ -637,9 +637,7 @@ class PaymentManualService
private function triggerEvent(string $name, array $payload): void
{
try {
if (class_exists(\CodeIgniter\Events\Events::class)) {
\CodeIgniter\Events\Events::trigger($name, ...$payload);
} elseif (function_exists('event')) {
if (function_exists('event')) {
event($name, $payload);
}
} catch (\Throwable $e) {
@@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
/**
* CodeIgniter {@see \App\Controllers\PrintRequests} parity (SPA JSON + uploads).
* legacy {@see \App\Controllers\PrintRequests} parity (SPA JSON + uploads).
*/
class PrintRequestsPortalService
{
@@ -120,7 +120,7 @@ class PrintRequestsPortalService
}
/**
* Admin queue ordering per CI raw SQL.
* Admin queue ordering per legacy raw SQL.
*
* @return list<array<string, mixed>>
*/
@@ -365,7 +365,7 @@ class PrintRequestsPortalService
}
/**
* Teacher dashboard payload (parity with CI teacher_index).
* Teacher dashboard payload (parity with legacy teacher_index).
*
* @return array{print_requests: list<array<string, mixed>>, sundays: list<string>, times: list<string>, class_id: int|null}
*/
@@ -510,7 +510,7 @@ class PrintRequestsPortalService
}
/**
* Copy-center request without uploading a file (CI createCopy).
* Copy-center request without uploading a file (legacy createCopy).
*
* @param array<string, mixed> $data class_id, num_copies, required_by, pickup_method
*/
@@ -7,7 +7,7 @@ use App\Models\Competition;
use Illuminate\Support\Facades\DB;
/**
* CodeIgniter {@see \App\Controllers\WinnersController} — public published winners pages.
* legacy {@see \App\Controllers\WinnersController} — public published winners pages.
*/
class PublicWinnersPortalService
{
@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\DB;
class StudentScoreCardService
{
/**
* Students shown on the score-card picker (CI `StudentController::scoreCardList` parity).
* Students shown on the score-card picker (legacy `StudentController::scoreCardList` parity).
* Teachers: only students in `class_section_id` for `school_year` after `teacher_class` check.
* Parents: their children only. Other roles: active students (optional search/limit).
*
@@ -25,7 +25,7 @@ class StudentScoreCardService
?int $classSectionId,
?string $schoolYear,
): array {
$rolesLower = array_map('strtolower', $user->roleNamesLikeCodeIgniter());
$rolesLower = array_map('strtolower', $user->roleNames());
$isTeacher = in_array('teacher', $rolesLower, true) || in_array('teacher_assistant', $rolesLower, true);
$isParent = in_array('parent', $rolesLower, true);