Skip to content

feat: share flags with Inertia via middleware - #4

Merged
shavonn merged 1 commit into
mainfrom
inertia-middleware
Jan 14, 2026
Merged

feat: share flags with Inertia via middleware#4
shavonn merged 1 commit into
mainfrom
inertia-middleware

Conversation

@shavonn

@shavonn shavonn commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 14, 2026 00:55
@shavonn
shavonn merged commit 5f599b7 into main Jan 14, 2026
17 checks passed
@shavonn
shavonn deleted the inertia-middleware branch January 14, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Inertia.js integration to share feature toggle flags with frontend applications. It introduces a middleware that automatically exposes all toggles to Inertia components.

Changes:

  • Adds ShareTogglesWithInertia middleware to share feature flags via Inertia props
  • Updates composer.json to include inertiajs/inertia-laravel as a dev dependency
  • Adds documentation for Inertia integration with usage examples
  • Applies Laravel Pint code style formatting to CreateCommand.php

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Middleware/ShareTogglesWithInertia.php New middleware that extends Inertia's base middleware to share all toggles as 'flags' prop
composer.json Adds inertiajs/inertia-laravel ^2.0 to require-dev dependencies
README.md Documents how to use the new Inertia middleware with code examples
src/Commands/CreateCommand.php Code style formatting changes (spacing, brace placement) via Laravel Pint

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment on lines +191 to +200
Share all toggles with your frontend by using the provided Inertia middleware. Replace your `HandleInertiaRequests` middleware in `bootstrap/app.php`:

```php
use OffloadProject\Toggle\Middleware\ShareTogglesWithInertia;

->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
ShareTogglesWithInertia::class,
]);
})

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states "Replace your HandleInertiaRequests middleware" but the code example shows appending the middleware using append: [ShareTogglesWithInertia::class]. This is inconsistent and misleading. The middleware extends Inertia\Middleware and overrides the share method to add flags, so it should indeed replace the default HandleInertiaRequests middleware, not be appended to it. The code example should either use a replacement approach or the description should be clarified to indicate that this extends the existing HandleInertiaRequests setup.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +22
class ShareTogglesWithInertia extends Middleware
{
/**
* Share Toggle feature flags with Inertia
*/
public function share(Request $request): array
{
return [
...parent::share($request),
'flags' => Toggle::all(),
];
}

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new ShareTogglesWithInertia middleware lacks test coverage. The project has comprehensive test coverage for other features (as seen in tests/Feature/), and this new middleware should also have tests to verify that it correctly shares toggles with Inertia props. Consider adding a test that verifies the middleware properly calls Toggle::all() and includes the flags in the shared props.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants