- How do I add the PennantTool to a Laravel Nova resource like User?
- Add `PennantTool::make()` to your resource’s `fields()` method. For example, include it alongside other fields like `ID::make()` or `Text::make('Name')`. The tool will appear in Nova’s resource detail view for managing feature flags.
- What Laravel and Nova versions does `laravel/nova-pennant` support?
- The package requires **Laravel 8+ or 9+** and **Nova 4.x+**. Check the package’s `composer.json` for exact version constraints, as compatibility may vary with minor updates. Older versions may need adjustments.
- Can I restrict who can toggle feature flags in Nova?
- Yes. Use the `canRun()` method to define authorization logic. For example, restrict toggling to admins with `->canRun(fn ($request) => Nova::user($request)->admin)`. This leverages Nova’s built-in user system.
- Does this package work without Pennant installed?
- No. `laravel/nova-pennant` is a **Nova UI layer** for Pennant’s feature flags. You must first install `pennant/pennant` via Composer and configure feature flags in your Laravel app before using this tool.
- How do I require password confirmation for toggling flags?
- Call `->requiresConfirmPassword()` on the `PennantTool::make()` method. This adds a password confirmation step before allowing users to activate or deactivate features, enhancing security.
- Can I use rich feature values (e.g., dropdowns) in Nova?
- Yes, if your Pennant feature uses a **class-based definition** with an `options()` method. The tool will automatically render the values as a dropdown or select input in Nova’s UI for that scope.
- Will adding PennantTool slow down Nova’s performance?
- Minimal impact is expected, but Pennant evaluations are still executed. For large-scale apps, cache Pennant results using Laravel’s cache or Pennant’s built-in caching to reduce latency in Nova.
- Can I integrate this with a custom Nova resource, not just User?
- Absolutely. Add `PennantTool::make()` to any Nova resource’s `fields()` method. It’s designed to work flexibly across resources like `Settings`, `Team`, or even custom models.
- Are there alternatives to `laravel/nova-pennant` for managing feature flags in Nova?
- If you’re not using Pennant, consider **Laravel’s built-in feature flags** or third-party packages like `spatie/laravel-feature-flags` with custom Nova tools. However, `nova-pennant` is the official bridge for Pennant users.
- How do I test PennantTool in my Nova application?
- Test by mocking Pennant evaluations in your Nova resource tests. Verify that toggling flags updates Pennant correctly and that authorization (e.g., `canRun()`) blocks unauthorized users. Use Nova’s testing helpers like `actingAs()` for user context.