# Wiring the Phase 1 overlay into the starter kit

After copying the files, make these edits to hook them into the framework.

## 1. Register the service provider — `bootstrap/providers.php`
```php
return [
    App\Providers\AppServiceProvider::class,
    App\Platform\Providers\PlatformServiceProvider::class, // add
];
```

## 2. Register the middleware alias — `bootstrap/app.php`
Inside `->withMiddleware(function (Middleware $middleware) { ... })`:
```php
$middleware->alias([
    'resolve.organization' => \App\Platform\Http\Middleware\ResolveOrganization::class,
]);
```

## 3. Extend the User model — `app/Models/User.php`
```php
use App\Platform\Concerns\HasOrganizations;

class User extends Authenticatable
{
    use HasOrganizations; // add to the existing use list

    protected $fillable = [
        'name', 'email', 'password',
        'current_organization_id', 'platform_role', // add these two
    ];
}
```

## 4. Share tenant + permission props with Inertia — `app/Http/Middleware/HandleInertiaRequests.php`
In the `share()` return array:
```php
'organization' => fn () => [
    'current' => $request->user()?->currentOrganization,
    'memberships' => $request->user()?->organizations()->get(['organizations.id', 'name']) ?? [],
],
'auth' => [
    'user' => $request->user(),
    'can' => $request->user()
        ? collect(\App\Platform\Authorization\PermissionRegistry::permissions())
            ->mapWithKeys(fn ($p) => [$p['key'] => $request->user()->can($p['key'])])
        : [],
    'isPlatformAdmin' => (bool) $request->user()?->isPlatformAdmin(),
],
```

## 5. Point the sidebar at the nav config
In the starter kit's `resources/js/components/app-sidebar.tsx`, import `primaryNav`
and `adminNav` from `@/config/navigation` and render them, gating each item on
`auth.can[item.permission]` / `auth.isPlatformAdmin`. Drop in `OrganizationSwitcher`
at the top. (The starter kit already provides the collapsible sidebar shell,
tooltips-when-collapsed, and persisted state — you are only supplying the items.)
