# CCT Laravel Conversion — audit and status

## Target stack
- Laravel 13 (`^13.0`), PHP 8.3+, MySQL 8 / compatible MariaDB.
- Existing CCT visual palette retained: navy / indigo, violet, pink-coral, pale lavender and gold.
- New Laravel database; old database remains read-only during migration.

## Source archive audit
The uploaded archive contains 31 entries. The main business logic is concentrated in `index.php` (~295 KB) and `csc/index.php` (~53 KB), with shared helpers in `includes/bootstrap.php` and `includes/login_otp.php`. It is a monolithic PHP application, not an existing MVC codebase. The original PHP, CSS, SQL, images and setup notes are preserved under `legacy-reference/`.

## Identified feature inventory from the supplied source
- Public portal, homepage settings, hero/secondary sliders, ticker, notices, contact, schedule, answer-key and policy pages.
- First-admin setup, login/logout, login OTP, role-aware admin/staff/candidate/CSC access.
- Candidate registration wizard, PIN lookup/location directory, OTP send/verify, application status, application PDF/proof handling.
- Exam configuration, exam eligibility PINs, centre management, roll/seat allocation, centre roll ranges, admit-card issuance/revocation, admit PDF/signature, attendance, marks and results import/export.
- Team member management and homepage visibility.
- Admin users and staff permissions.
- Notification campaigns, audience/scope/status selection, email and WhatsApp channels, template/language configuration, delivery logs and channel switches.
- CSC operator registration/login, candidate submissions, private drafts, wallet transactions, commission, payout profile and payout requests.

## Implemented in this Laravel foundation
- Laravel 13 project manifest and Laravel application bootstrap/routing structure.
- Role middleware for superadmin/admin/staff, candidate and CSC operator.
- Initial Super Admin creation, login/logout using the legacy `password_hash` column.
- Public homepage data read for notices and published exams.
- Basic role-specific dashboard shells.
- Fresh-schema migration based on supplied `database.sql` plus runtime-created extension tables identified in the PHP source.
- `cct:import-legacy` command to copy the known tables from a separately configured legacy MySQL connection without deleting source records.
- CCT palette and responsive dashboard styling.

## Not yet ported — do not deploy as a feature-complete replacement
The original workflows are preserved as reference source but still need individual Laravel controllers, form requests, policies, jobs/services, Blade screens and automated regression tests. This includes candidate registration and file uploads; OTP and email/WhatsApp delivery; complete exam CRUD; PIN/location import; application verification; roll/seat allocation; admit card generation; attendance and marks; result import/export; notifications and channel toggles; admin/staff permission editor; homepage CMS; CSC draft, wallet, commission and payout flows; all reports and PDFs. Some legacy schema columns are added dynamically at runtime in the PHP source and require a final schema reconciliation against a live database export before production migration.

## Installation
1. Use PHP 8.3+ and MySQL/MariaDB. Create a NEW empty database, e.g. `cct_laravel`.
2. Upload/extract this project outside the public web root; set the domain document root to this project's `public/` directory.
3. Run `composer install --no-dev --optimize-autoloader`.
4. Copy `.env.example` to `.env`, set `APP_URL`, `APP_KEY`, and the NEW database credentials.
5. Run `php artisan key:generate`, `php artisan migrate --force`, `php artisan storage:link`.
6. Create a separate Laravel DB connection named `legacy` in `config/database.php` (or add it as described below) using the OLD database credentials, then run `php artisan cct:import-legacy`.
7. Verify row counts and relationships before changing DNS or production traffic.
8. Visit `/setup` to create the first Super Admin if no admin rows were imported.

### Configure the legacy connection
The `legacy` connection is already defined in `config/database.php`; set `LEGACY_DB_HOST`, `LEGACY_DB_PORT`, `LEGACY_DB_DATABASE`, `LEGACY_DB_USERNAME`, `LEGACY_DB_PASSWORD` in `.env`. Keep the old database read-only during import. Use `--truncate` only on a disposable target database.

## Important migration notes
- Importer uses `insertOrIgnore`; duplicate primary keys are skipped. The importer compares source/target columns and warns about source-only columns rather than crashing; any such warning must be resolved in schema before final production migration. It is intended for a fresh empty target database and a one-time initial import. Verify row counts table-by-table.
- Source tables not present in the archive's static SQL may have runtime-added columns. Before final import, export the live old database schema and reconcile all columns/indexes, then test the import on a staging copy.
- File paths in old rows refer to the legacy `uploads/` folder. The files are preserved in `legacy-reference/uploads/`; file migration to Laravel `storage/app/public` and path rewriting remain to be implemented.
- OTP and notifications must not be enabled in production until provider credentials, queue delivery and rate limiting are ported and tested.
- This deliverable is a conversion foundation, not a completed production replacement. Do not point the live domain to it yet.
