# PhySci Campus API

The API is served from Laravel's `/api` prefix. Set the frontend `VITE_API_BASE_URL` to the backend URL ending in `/api`.

## Local setup

1. Copy `.env.example` to `.env` and set `DB_*`, `APP_KEY`, and the `INITIAL_ADMIN_*` values.
2. Run `composer install`.
3. Run `php artisan key:generate`.
4. Run `php artisan migrate --seed`.
5. Start the API with `php artisan serve`.

The frontend uses token authentication: login and registration return `data.token`; send it as `Authorization: Bearer <token>`. Protected responses require JSON `Accept` headers.

## Booking example

```http
POST /api/bookings
Authorization: Bearer TOKEN
Content-Type: application/json

{
  "room_id": 1,
  "booking_date": "2026-08-30",
  "start_time": "09:00",
  "end_time": "11:00",
  "purpose": "Geology tutorial class"
}
```

Only approved bookings block an interval. Approval checks overlap transactionally and returns `409 Conflict` when another approved booking occupies the requested room and time. Every transition is written to `booking_status_history`.

Configure Laravel CORS to allow the Vite origin (`http://localhost:5173`) during development. Use HTTPS and restricted production origins in deployment.
