# PHP Laravel PostgreSQL event space booking

An event space site lets visitors compare rooms, reserve a future time, and avoid conflicting bookings. Tokay runs the Laravel page as a Web Service and checks upcoming reminders with a Scheduled Service.

This project has the shape of a real app with public requests and scheduled work over one PostgreSQL database. Tokay recognizes both entry points and lets them share the database and encrypted Laravel key inside one Project.

## Facts

- Runtime: PHP
- Framework: Laravel
- Service types: Web Service, Scheduled Service
- Resources: PostgreSQL
- Required secrets: `APP_KEY`

## What it does

The public page introduces three rooms with their capacity, description, and hourly price.

Choose a room, start time, duration, and purpose, then press **Confirm booking**. The page saves valid requests and tells you when someone already holds an overlapping time.

The optional **Upcoming bookings** page gives staff a private list. The reminder Service records bookings due within 24 hours and can send email when you add SMTP settings.

## Deploy it

Bring this folder to Tokay any way you like. Paste or upload it in the dashboard, push it with git, or hand it to your AI agent along with [our agent instructions](https://app.tokay.io/llms.txt). Tokay figures out the rest.

Working in Claude, ChatGPT, VS Code, or another MCP client? Connect the [Tokay MCP server](https://tokay.io/docs/platform-mcp) and ask your agent to deploy this example. It signs in through your browser, so there is no token to paste.

New to Tokay? The [getting started guide](https://tokay.io/getting-started) walks you through your first deploy.

## Generate the required secret

Generate a value on your own computer.

```bash
php -r "echo 'base64:'.base64_encode(random_bytes(32)).PHP_EOL;"
```

Keep the value ready for the setup step after Tokay creates both Services. Do not put it in this folder.

## Finish setup in Tokay

On the Project page, choose **Secrets**. Find `APP_KEY` under **Required setup**, choose **Set shared value**, paste the value you generated, and save it. Both Services will use this same encrypted value.

Next, open each Service's **Environment** page. Under **From your infrastructure**, find `DATABASE_URL`, choose **Confirm database**, keep `app`, then choose **Confirm**. Do this for both Services so each one receives the same Project resource and logical database.

Check that `APP_KEY` and `DATABASE_URL` say **Good to go** on both Services. Follow both deployment trackers and choose **Go Live** anywhere that action appears. When the Web Service status says **Live**, click its live URL in the top section to open the booking page.

## Try it

1. Book the **Workshop** room, then try to reserve an overlapping time. The second request is rejected.
2. Open the reminder Service and choose **Run Now** twice. The first run records a due reminder and the second skips the duplicate.
3. Deploy again and return to the booking site. Your original reservation remains.

## Turn on staff and email features

Set `ADMIN_PASSWORD` under **From your code** on the Web Service's **Environment** page, then deploy the Web Service again. Open `/admin/bookings` and enter the password to see upcoming names, rooms, and times.

The Scheduled Service records reminders in its run history by default. To send real email, set `SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, and `SMTP_FROM` under **From your code** on its **Environment** page. Add a booking due within 24 hours, then choose **Run Now**.

## How it works

Wondering how both Services agree on a booking? The Web Service owns the Laravel migrations for their shared database. Tokay tests `php artisan migrate --force` against a copy before the site receives traffic, while the reminder job connects without trying to own the schema.

A database lock lets only one overlapping request win for a room and time. The reminder command records each notification before optional email delivery, so the next hourly run can safely skip it.

## Secrets

| Name | Required | Purpose |
| --- | --- | --- |
| `APP_KEY` | Yes | Encrypts Laravel application values. Share one Project value with both Services. |
| `ADMIN_PASSWORD` | No | Opens the staff booking list on the Web Service. |
| `SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_FROM` | No | Sends real reminder email from the Scheduled Service. |

## Grow from here

Try the [daily sales report](/examples/python-postgres-daily-sales-report) when a scheduled job should create something people revisit.

## Source files

- [reminders/artisan](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/reminders/artisan)
- [reminders/composer.json](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/reminders/composer.json)
- [web/app/Models/Booking.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/app/Models/Booking.php)
- [web/app/Models/Notification.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/app/Models/Notification.php)
- [web/app/Models/Room.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/app/Models/Room.php)
- [web/app/Providers/AppServiceProvider.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/app/Providers/AppServiceProvider.php)
- [web/artisan](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/artisan)
- [web/bootstrap/app.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/bootstrap/app.php)
- [web/bootstrap/providers.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/bootstrap/providers.php)
- [web/composer.json](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/composer.json)
- [web/config/app.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/app.php)
- [web/config/auth.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/auth.php)
- [web/config/cache.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/cache.php)
- [web/config/database.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/database.php)
- [web/config/filesystems.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/filesystems.php)
- [web/config/logging.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/logging.php)
- [web/config/mail.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/mail.php)
- [web/config/queue.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/queue.php)
- [web/config/services.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/services.php)
- [web/config/session.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/config/session.php)
- [web/database/migrations/2026\_07\_18\_000001\_create\_booking\_tables.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/database/migrations/2026_07_18_000001_create_booking_tables.php)
- [web/public/.htaccess](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/public/.htaccess)
- [web/public/index.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/public/index.php)
- [web/public/site.css](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/public/site.css)
- [web/resources/views/admin.blade.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/resources/views/admin.blade.php)
- [web/resources/views/home.blade.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/resources/views/home.blade.php)
- [web/routes/web.php](https://tokay.io/examples/src/php-laravel-postgres-event-space-booking/web/routes/web.php)

## Download and source

- [Download the complete project](https://tokay.io/examples/downloads/php-laravel-postgres-event-space-booking.zip)
- Last updated: 2026-07-31
- Example revision: `52c7b7f`
- [View this revision on GitHub](https://github.com/tokayio/tokay-examples/tree/52c7b7ffd52e157375b08f1f11ff4fbe6c498642/php-laravel-postgres-event-space-booking)
- [Deploy a Laravel app](https://tokay.io/use-cases/deploy-laravel)
