# PHarking (Laravel 12 Upgrade)

PHarking is a single-marketplace SaaS for reserving available parking spaces in Metro Manila.

This repository has been modernized to Laravel 12 architecture with:

- Blade public pages
- Livewire directory and dashboard modules
- Action/Service-based business logic
- Migration-first schema with factories and seeders
- API v1 listing resources for V2 mobile readiness

## Prerequisites

- PHP 8.2+
- Composer 2.7+
- MySQL 8+ by default. SQLite and PostgreSQL remain supported for targeted local/test use.
- PHP PDO extension for your selected database:
  - `pdo_sqlite`
  - `pdo_mysql` (MySQL)
  - `pdo_pgsql` (PostgreSQL)

## Install

```bash
cp .env.example .env
composer install
php artisan key:generate
php artisan storage:link
```

## Database

This project defaults to MySQL.

```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pharking
DB_USERNAME=pharking
DB_PASSWORD=pharking
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
```

For Docker development, `docker-compose.override.yml` starts a local MySQL
container and injects these connection values into the app container.

SQLite and PostgreSQL are still available by setting the appropriate `DB_*`
values in `.env` or the runtime environment.

### PostgreSQL

```env
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=pharking
DB_USERNAME=postgres
DB_PASSWORD=
DB_CHARSET=utf8
DB_SCHEMA=public
DB_SSLMODE=prefer
```

### Run migrations and seeds

```bash
php artisan migrate
php artisan db:seed
```

## Run

```bash
php artisan serve
```

## Quality Commands

```bash
composer test
composer lint
composer analyse
```

## API v1

- `GET /api/v1/listings`
- `GET /api/v1/listings/{listing}`

## Auth and Roles

- Session auth for V1 web
- Roles: `admin`, `host`, `member`
- Status gate: suspended users are blocked from protected routes

## Notes

- Booking timestamps are stored in UTC.
- Listing timezone defaults to `Asia/Manila`.
- Money values are stored as integer cents (`*_cents`).
- Booking overlap prevention is enforced in code with transaction + `lockForUpdate()`.

## CI Suggestion

Run at minimum:

```bash
composer test
```

Recommended full gate:

```bash
composer test && composer lint && composer analyse
```
