Filament Menu "Paywall": Show Items but Restrict Access

Filament 4

Demonstrates how to have "premium" menu items which are shown on the sidebar but lead to "locked" pages with buttons to pay for premium.

Untitled design (3)

Get the Source Code:

How it works

It's inspired by a question on the official Filament Discord:

So, this project shows four Filament Resources:

  • Tasks (free)
  • Projects, Tags, Categories (paid)

Notice 1: The project doesn't implement the payments/subscriptions. It's simplified and focused on just menu items show/hide, using just users.is_subscribed DB column.

Notice 2: those resources are also "placeholders", without any DB data or Filament columns/inputs, just to show the situation.

If a non-subscribed user clicks on any Paid resource, they are redirected to the speficic Locked page, with the resource as a part of the URL, for future redirect after the payment.

To check each page for access, there's a global SubscriptionMiddleware assigned to all Filament routes.

app/Http/Middleware/SubscriptionMiddleware.php:

class SubscriptionMiddleware
{
private array $paidResources = [
'tags',
'projects',
'categories',
];
 
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (!auth()->user()->is_subscribed) {
// ...
The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 152 Premium Examples for $99