# cPanel Deployment Notes

## Server Requirements

- PHP 8.2 or newer. The current `public/error_log` shows the live host ran PHP 7.4.33, which will break admin login before Laravel can load.
- MySQL or MariaDB database.
- Composer dependencies from the included `vendor` folder or a Composer install run on a PHP 8.2 environment.
- The web root should point to `public/`. If the host keeps the app at `/public/`, leave the existing public URL style in place.

## Upload And Configure

1. Upload the project files to the hosting account.
2. Back up the target database, then import `sabetiay_topskills.sql` into the production database. The V1.5 SQL remains import-safe for full restores and drops existing dumped tables before recreating them.
3. Copy `.env.example` to `.env` and set `APP_URL`, `APP_KEY`, database credentials, mail settings, and the `CFSAAS_DEMO_RESET_KEY`.
4. Confirm the domain is using PHP 8.2+ in cPanel MultiPHP Manager.
5. Run the app schema/update endpoint once: `https://topskills-experts.com/public/schema`.
6. Run the data/import endpoint only if you intentionally want demo/sample records: `https://topskills-experts.com/public/data`. The production SQL already includes live content, and V1.5 makes this importer tolerate the `cf_industries` table without timestamps.
7. Log in to `/admin/login`, open `Plugins`, and confirm the active modules.
8. Open `Demo Requests` to approve or reject buyer demo access.
9. Open `HRM Preview` only if you want to seed or review the optional HRM plugin preview data.

## V1.3 Modules

- Plugins registry: `/admin/plugins`
- ATS Resume Builder for front candidates: `/account/ats-resume-builder`
- ATS Resume Builder for employer-branded candidate portals: `/{employer-slug}/account/ats-resume-builder`
- IP tracking log: Admin -> Plugins -> Recent IP tracking log
- Public consultant registration preview: `/hr-consultants`
- HRM plugin preview: `/admin/hr-suite` and `/employer/hrm`

## HRM Plugin Preview

- HRM is positioned as a plugin-ready extension, not a replacement for the original Candidate Finder core.
- Consultant packages are sample commercial plans and can be adjusted in the backend/database.
- Consultants log in through the employer workspace and can be marked with `consultant_mode = 1`.
- Client and staff limits are stored on the consultant account and subscription record.
- The preview links recruitment to HRM by seeding a candidate/application handoff into `hr_employees`.

## Demo Environment

- Public request page: `/demo/request`
- Approved access links expire after 72 hours by default.
- Demo banner text is shown when `CFSAAS_DEMO=true`, `CFSAAS_DEMO_STRICT=true`, or a visitor opens an approved demo link.
- Reset endpoint: `/demo/reset/{CFSAAS_DEMO_RESET_KEY}`
- Recommended cron for 30-minute resets:

```bash
*/30 * * * * curl -fsS https://topskills-experts.com/public/demo/reset/YOUR_RESET_KEY >/dev/null 2>&1
```

Keep `CFSAAS_DEMO=false` on the main production instance unless you intentionally want the whole site to display demo mode. Approved buyer demo links can still show the banner through the visitor session.

For a shared production database, demo sessions are write-protected through the app's demo guard so buyers do not change the live business instance. For a fully mutable buyer sandbox, create a separate cPanel subdomain and database, import the same files, set `CFSAAS_DEMO=true`, and use the 30-minute reset cron there.

## Smaller Release Uploads

Use `TopSkills-HR-SaaS-Update-V*.zip` for ordinary upgrades. It contains changed files only and is much smaller for upload/download. Keep the live `vendor/`, `.env`, and `storage/uploads` in place.

Use a source ZIP only for a rebuild. Source ZIPs exclude `.env` and may exclude `vendor/`; Composer must run under PHP 8.2+ if `vendor/` is missing.

## Database Import Error At `cf_blogs`

If phpMyAdmin shows a failed query around `CREATE TABLE cf_blogs`, the usual cause is importing over an existing database. V1.5 includes:

- `sabetiay_topskills.sql`: import-safe full restore dump.
- `database/sabetiay_topskills_import_safe.sql`: same import-safe dump.
- `database/sabetiay_topskills_original.sql`: untouched original dump.

Use the import-safe SQL when you want to replace the target database. Use the original only when importing into a truly empty database.

## DataTables Ajax Error On Candidates

If DataTables shows `table id=candidates_datatable - Ajax error`, check the Laravel log for the real SQL error. V1.5 guards the candidate grid against older databases that have not yet added `account_type`, but you should still open `/schema` once after upload so the HRM/demo/ATS columns are created.

## `/data` Import Error At `cf_industries`

If `/data` previously failed with `Unknown column 'created_at' in 'field list'` on `cf_industries`, upload V1.5 and retry only if you need sample data. The importer now adds timestamp fields only when the target table actually has them.

## Demo Credentials

These are created by the HR Suite/demo seed module if they do not already exist.

- Admin: `admin@topskills-experts.com` / `admin`
- Employer: `employer@topskills-experts.com` / `employer`
- User/Visitor: `user@topskills-experts.com` / `user`

Change the defaults in Admin Settings after first deployment if the public demo will be exposed widely.
