# PETROGUIN Platform — Build Conventions (read before coding)

A single Laravel 11 app. One shared MySQL database (`petroguin`). One login (Breeze Blade + Tailwind).
Six integrated modules share the same `employees`, `departments` and `users` tables.

## Core tables that ALREADY EXIST (do not recreate; you may FK to them)
- `users` (id, name, email, password, role, employee_id)
- `departments` (id, name, code, description, manager_id)
- `employees` (id, employee_no, first_name, last_name, email, phone, department_id,
  job_title, hire_date, date_of_birth, address, employment_status[active|on_leave|terminated],
  base_salary, user_id)

Core models: `App\Models\User`, `App\Models\Department`, `App\Models\Employee`
(`$employee->full_name` accessor exists; `Employee::active()` scope exists).

## File layout for YOUR module
- Migrations: `database/migrations/` — prefix with the date prefix you are told to use so order is correct.
- Models: `app/Models/*.php`, namespace `App\Models`.
- Controllers: `app/Http/Controllers/<ModuleDir>/*.php`, namespace `App\Http\Controllers\<ModuleDir>`.
- Routes: WRITE ONLY your own file `routes/modules/<module>.php`. It is auto-required inside the
  `auth` middleware group. Do NOT edit `routes/web.php`. Define routes with `Route::resource(...)` etc.
- Views: `resources/views/<module>/...`.
- Seeder: create `database/seeders/<Name>Seeder.php` (a class). DO NOT edit DatabaseSeeder — the
  orchestrator registers it.

## Cross-module foreign keys
- You MAY add a real FK constraint to `employees`, `departments`, `users` (they exist first).
- For references to tables owned by OTHER modules (e.g. projects, documents), use a plain
  `unsignedBigInteger(...)->nullable()->index()` column WITHOUT `->constrained()` to avoid
  migration-order problems. Still define the Eloquent relationship on the model.

## URL prefixes (must match exactly — the sidebar links to these)
See each module task for its exact prefixes.

## Views — use the shared shell
Every page:
```blade
<x-app-layout>
    <x-slot name="header">Page Title</x-slot>
    ... content ...
</x-app-layout>
```
Reusable components available:
- `<x-ui.card title="...">...</x-ui.card>`
- `<x-ui.stat label="..." :value="..." color="blue|green|amber|rose|slate" />`
Use Tailwind utility classes. Tables: `class="min-w-full text-sm"`, header row `bg-slate-50 text-left text-slate-500`,
cells `px-4 py-2 border-b border-slate-100`. Buttons: primary `inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm rounded-md hover:bg-blue-700`.
Always include `@csrf` in forms and `@method('PUT'|'DELETE')` where needed.

## Controllers
Standard resourceful methods. Validate input. Redirect back with `->with('status', '...')`.
Keep it functional and clean; this is a working app, not a stub.

## Money
Currency is XOF (no decimals shown): `'XOF '.number_format($value)`.
