# Users & Profiles

Turista uses a single `users` table as the shared identity for all actors. Role-specific data lives in profile tables.

## User model

`App\Models\User` stores:

- `name`
- `email` (unique)
- `phone` (unique)
- `password` (hashed)
- `is_verified`
- timestamps and soft deletes

A user has one of the following profiles:

- `Owner`
- `Employee`
- `Customer`

## Roles

Spatie Laravel Permission assigns one role per user:

- `super_admin`
- `admin`
- `owner`
- `employee`
- `customer`

## Owner profile

`App\Models\Owner` stores:

- `status` — `pending`, `active`, or `suspended`
- `whatsapp_number`
- `is_verified`

The primary key `id` is also a foreign key to `users.id`. An owner has many `Buildings`, `Employees`, and `Units` through buildings.

Owners must be approved (`status = active`) before they can list properties or accept reservations.

## Employee profile

`App\Models\Employee` stores:

- `owner_id` — the owner they work for
- `building_id` — optional building assignment
- `status` — `active` or `suspended`

Employees act on behalf of an owner and can manage reservations and related data. Their access is scoped to their owner (and optionally building).

## Customer profile

`App\Models\Customer` stores:

- `whatsapp_number`
- `wallet` (decimal)

Customers make online bookings and receive receipts. The wallet can be used for payments or receive refunds.

## Pending customer

`App\Models\PendingCustomer` supports the on-arrival booking flow. When a guest arrives without a prior account, the owner/employee can create a pending reservation linked to a pending customer. The guest verifies their phone number via OTP, at which point the pending customer is converted or linked to a real customer.

## Key flows

- **Owner registration:** `User` + `Owner` created; OTP sent; admin verifies owner after activation.
- **Customer registration:** `User` + `Customer` created; OTP sent.
- **On-arrival booking:** `PendingCustomer` created with phone; OTP verified; reservation confirmed.
- **Password reset:** token generated and emailed; user resets password.
