Skip to content

feat: Add plan features and gating middleware - #12

Open
kofimokome wants to merge 3 commits into
mainfrom
feat/entitlement
Open

feat: Add plan features and gating middleware#12
kofimokome wants to merge 3 commits into
mainfrom
feat/entitlement

Conversation

@kofimokome

@kofimokome kofimokome commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Fixes #8

Depends on #11

@kofimokome
kofimokome marked this pull request as ready for review July 6, 2026 20:27
@sourceant

sourceant Bot commented Jul 6, 2026

Copy link
Copy Markdown

Code Review Summary

This PR introduces a feature gating mechanism including a dedicated middleware GateFeature and its registration within the CloudServiceProvider. The implementation is generally sound and integrates well with the existing entitlement logic.

🚀 Key Improvements

  • Implementation of GateFeature middleware to enforce plan-based entitlements.
  • Centralized registration of the cloud.feature middleware alias in CloudServiceProvider.php.

💡 Minor Suggestions

  • Refactor GateFeature to use constructor injection for the Entitlements service.

@sourceant sourceant Bot 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.

Review complete. See the overview comment for a summary.

Comment thread config/cloudplans.php Outdated
Comment thread src/Support/CloudEntitlements.php Outdated
Comment thread database/migrations/2019_05_03_000002_create_subscriptions_table.php Outdated
@kofimokome
kofimokome requested a review from nfebe July 6, 2026 20:29

@nfebe nfebe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seem to have same commits as #11... I am a bit confused just 11 has 1 extra commit.

@kofimokome

Copy link
Copy Markdown
Collaborator Author

@nfebe it depends on #11. so you would have to review #11 first before this one.
I also added in the description that it depends on #11.

@kofimokome

Copy link
Copy Markdown
Collaborator Author

it's not possible to work on this without the changes in #10 (stripe integration) and #11 (entitlements integration)

@kofimokome
kofimokome marked this pull request as draft August 3, 2026 19:07
# Conflicts:
#	src/CloudServiceProvider.php

# Conflicts:
#	src/CloudServiceProvider.php
@kofimokome
kofimokome marked this pull request as ready for review August 24, 2026 17:37

@sourceant sourceant Bot 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.

Review complete. See the overview comment for a summary.

Comment thread database/migrations/2026_06_16_201941_create_ai_usage_counters_table.php Outdated
Comment thread src/Support/CloudEntitlements.php Outdated
Comment thread src/Support/CloudEntitlements.php Outdated
Comment thread src/Models/AiUsageCounter.php Outdated

@sourceant sourceant Bot 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.

Review complete. See the overview comment for a summary.

use Symfony\Component\HttpFoundation\Response;
use Whilesmart\Entitlements\Contracts\Entitlements;

class GateFeature

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use constructor injection for the Entitlements service instead of resolving it via the app() helper inside the handle method. This promotes better testability by allowing dependencies to be mocked easily and follows standard Laravel middleware patterns.

Suggested change
class GateFeature
class GateFeature
{
public function __construct(
protected Entitlements $entitlements
) {}
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param string $feature
* @return Response
*/
public function handle(Request $request, Closure $next, string $feature): Response
{
if (!$this->entitlements->allows($request->user(), $feature)) {

@kofimokome
kofimokome requested a review from nfebe August 24, 2026 17:47
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.

feat(cloud): Implement Entitlements with plan features and gating middleware

2 participants