- How do I add an impersonate action to a Filament resource table?
- Edit your `UserResource` class and add `Impersonate::make()` to the `actions` array inside the `table` method. For example: `->actions([Impersonate::make()])`. This adds a clickable button in the table row for each user.
- Does this package work with Laravel Sanctum or Passport?
- Yes, but you must explicitly specify the guard using `->guard('sanctum')` or `->guard('api')` when configuring the impersonate action. The default guard is Filament’s primary guard, so ensure your Sanctum/Passport routes are properly configured.
- Can I customize the redirect URL after impersonation?
- Absolutely. Use `->redirectTo(route('dashboard'))` or any valid route/URL in the `Impersonate::make()` configuration. For non-Livewire routes, add `->withoutSpa()` to force a full page reload in SPA panels.
- Is this compatible with Laravel Octane (Swoole/FrankenPHP)?
- Yes, the package is tested for Octane compatibility. However, ensure your Octane driver (Swoole/FrankenPHP) is properly configured, as impersonation relies on session handling. No additional setup is required unless you encounter guard-specific issues.
- How do I restrict impersonation to specific users (e.g., admins only)?
- Override the `canImpersonate()` method in your `User` model or use Filament’s built-in authorization. For example, add `public function canImpersonate(): bool { return $this->isAdmin(); }` to your model. The package defaults to open impersonation if no logic is defined.
- Will impersonation work with soft-deleted users by default?
- No, the package blocks impersonation of soft-deleted users by default. To change this, set `IMPERSONATE_ALLOW_SOFT_DELETES=true` in your `.env` file. This is configurable to prevent accidental impersonation of inactive accounts.
- How do I add the impersonation banner to non-Filament layouts?
- Include the banner component directly in your Blade templates using `<x-impersonate::banner />`. This ensures session awareness outside Filament’s SPA context. The banner automatically appears when a user is being impersonated.
- Does this package support multilingual impersonation labels?
- Yes, it includes translations for Russian, Tajik, and Uzbek. Enable them by adding `config(['filament-impersonate.translations' => 'ru'])` (or your language code) in your `AppServiceProvider`. Custom translations can also be added via the `lang` directory.
- Can I log impersonation events for audit purposes?
- The package emits `EnterImpersonation` and `LeaveImpersonation` events, which you can listen to in an event service provider. For example, log these events to a database or third-party service for compliance tracking.
- What Laravel and Filament versions are supported?
- This package requires Laravel 10+ and Filament v3+. For Filament v5.x features, ensure you’re using the latest version of the package. Always pin your Filament version in `composer.json` to avoid compatibility issues during upgrades.