# Travelio update package

# Travelio full-source update

The same latest `WebSourceCode` project is used for both fresh installations and existing-site updates. Do not maintain a second, partial update package.

For automatic update, ZIP either the contents of `WebSourceCode` or the `WebSourceCode` directory itself. The updater accepts both layouts:

```text
travelio-v1.7.0.zip            travelio-v1.7.0.zip
├── travelio-update.json        └── WebSourceCode/
├── app/                           ├── travelio-update.json
├── config/                        ├── app/
└── ...                            └── ...
```

The full project must contain this manifest:

```json
{
  "version": "v1.7.0",
  "paths": ["app", "bootstrap", "config", "database", "lang", "Modules", "public", "resources", "routes"]
}
```

A release must declare **every** folder listed above. `bootstrap/` carries the middleware aliases the new routes use and `lang/` the translations of every new screen; a ZIP that leaves either out produces a site that errors or shows raw translation keys.

An optional `"requires": ["Vendor\\Package\\SomeClass"]` entry lists classes the release needs from `vendor/`; if one is missing the updater refuses **before** replacing any file and tells the admin to update `vendor/`.

## What is replaced and what is protected

- Replaced (only the folders the manifest declares): `app`, `bootstrap`, `config`, `database`, `lang`, `Modules`, `public`, `resources`, `routes`. Other full-project paths are ignored by the automatic updater. Files the new release no longer ships are not deleted.
- Never replaced: `.env`, `storage`, `vendor`, `public/uploads`, `public/storage`.
- `lang/*.json` translation files are **merged**, not overwritten: every new key is added, the value already on the site for an existing key (for example one edited under Languages → Phrases) is kept. New files and new languages are copied whole.

## Updating from any earlier version, including v1.0.0

Updates are cumulative. You can go **directly** from v1.0.0 (or v1.1.x / v1.2.x) to the current release in one run; versions are compared, never required to be sequential, and one run applies every pending migration and upgrade step. A site with no stored version is treated as v1.0.0.

Neither v1.0.0 nor v1.1.0 contains the System Update screen, so the first jump from those versions is the **cPanel / manual file copy** below. From then on the screen's ZIP upload works.

One finalize run (the **Finalize manual update** button, the ZIP upload, or `php artisan travelio:upgrade`) does, in order:

1. Applies every pending database migration. They are guarded (safe to resume if interrupted) and back-fill existing rows (booking gross amounts, payment and supplier status, vendor ledger accounts, …).
2. Refreshes permissions and roles. New permissions are added to existing roles **and** to the users who hold them (permissions are stored per user), without re-adding a permission an agency removed by hand and without dropping extras it added. Super-admins always get the full set.
3. Adds settings keys the release introduced (loyalty, reviews, AI, flight API, WhatsApp, payment gateways, booking policy, marketplace switch and commission, …). Insert-only: existing values — including an API key left blank — are never changed.
4. Adds shipped reference data that is missing: languages, home-page sections (only for a page that has none yet). Existing rows and edits are untouched.
5. Moves visa documents saved on the public disk (before v1.1.0) to private storage, once (`php artisan travelio:move-private-documents` is no longer a manual step), and creates the `public/storage` link if missing.
6. Clears config/route/view/event caches and resets the opcode cache, then records the new version.

The screen shows what was applied; the same lines are kept in `storage/app/updates/logs/`.

## `vendor/` and Composer

The ZIP never replaces `vendor/` (the package is shipped without it; buyers install it with `composer install --no-dev`). The release code runs against the `vendor/` folder of a v1.0.0 install: the only dependency that changed in a way the code depends on, `intervention/image` 2.7 → 3.x, is handled by supporting both versions, and the other package updates are patch/minor bumps. So **no `vendor/` replacement is required to go from 1.0.0**. If you have SSH, running `composer install --no-dev --optimize-autoloader` after the update is still recommended to pick up the current security patches. If a future release does need a new package, it declares it in `requires` (above) and the updater stops with a clear message before changing anything.

## cPanel fallback

If the server blocks ZIP uploads or extraction (and always for the first jump from v1.0.0 / v1.1.0, which has no System Update screen):

1. Take a full backup of the files and the database.
2. Extract the official ZIP locally. In cPanel File Manager copy/paste the **contents** of `WebSourceCode` (not the wrapper folder) including `travelio-update.json` into the project root and choose **Replace all**. Do not replace `.env`, `vendor`, `storage`, `public/uploads` or `public/storage`.
   With SSH/rsync use anchored excludes, otherwise any nested folder named `vendor` (older releases had `resources/views/backend/vendor`) is skipped: `rsync -avz --exclude='/.env' --exclude='/storage' --exclude='/vendor' --exclude='/public/uploads' --exclude='/public/storage' WebSourceCode/ /path/to/project/`
3. Sign in as the **super-admin** and open Admin → Settings → System update (any other admin page redirects there until the update is finalized). The release version is detected from `travelio-update.json`; click **Finalize manual update**. Do this promptly: until it runs, the public website and most admin pages point at database columns that do not exist yet.
4. With SSH you can run `php artisan travelio:upgrade` instead of step 3.

If finalize fails, nothing is half-recorded: the version is only saved at the end, the schema steps can resume, and you can run it again after fixing the cause. Backups of the replaced folders from the ZIP flow are in `storage/app/updates/backups`.

