how to hide resource for particular user in filament?
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
# How to Hide Filament Resources for Particular Users: Mastering Role-Based Access Control
As a senior developer working with powerful frameworks like Laravel and Filament, you frequently encounter the need to tailor the administrative interface based on the user's permissions. A common requirement is separating the view and functionality between an Administrator (who needs full access) and a standard User (who should only see their own data or limited views).
This post dives deep into how to effectively hide Filament resources and navigation elements for specific users, providing robust, scalable solutions. We will explore methods ranging from fine-grained authorization checks to architectural separation of entire panels.
## The Core Challenge: Controlling Visibility in Filament
When building applications with Filament, the structure of your interface is defined by the configuration of your Resources and Panels. To hide a resource like `StudentResource` from regular users, we cannot rely solely on hiding the route; we must control whether the user is *authorized* to see that navigation item in the first place.
The best approach hinges on Laravel's native authorization system, leveraging Roles or Policies.
## Solution 1: Implementing Fine-Grained Authorization via Policies
The most robust way to manage access in a Laravel applicationâand thus within Filamentâis by defining explicit permissions using **Policies**. A Policy dictates what an authenticated user is allowed to do on a specific Eloquent model.
While Filament doesn't offer a direct "hide this section if X" toggle, you can use Policies to conditionally gate the visibility of resources or actions.
**Example Concept (Conceptual):** If a user does not have the `view_students` permission defined in their role, we prevent access entirely.
In your resource definition, you can enforce checks:
```php
// In StudentResource.php
public static function getNavigationItems(Model $record): array
{
$user = auth()->user();
if ($user->hasRole('admin')) {
return parent::getNavigationItems($record); // Show all items
}
// Return only necessary navigation links for a regular user
return [
Filament\Navigation\NavigationItem::make('my_student_details')
->url(route('students.show', $record))
->visible(true),
];
}
```
**Why this works:** By forcing the Resource to check the authenticated user's attributes (via Roles or Policies) before rendering its navigation structure, you ensure that unauthorized users never see the link, leading to a cleaner UI. This pattern aligns perfectly with Laravel best practices, making your application more secure and maintainable, much like how we structure data relationships in Eloquent models on **https://laravelcompany.com**.
## Solution 2: Architectural Split â Creating Separate Panels (The Cleaner Approach)
For the scenario you describedâhaving a completely different interface for Admins versus standard Usersâthe most architecturally sound solution is to avoid trying to hide elements within a single panel and instead create two distinct interfaces.
We can achieve this by setting up two separate Filament installations or, more simply, defining two separate sets of navigation links that point to entirely different resource groups.
1. **Admin Panel:** Contains all sensitive resources (e.g., `StudentResource`, `UserManagementResource`). This panel is only accessible to users with the 'admin' role.
2. **User Panel:** Contains only user-specific resources (e.g., a simple `ProfileResource` or an area where they can view their own data).
This approach completely decouples the concerns: Admins manage system settings, and Users manage personal data. This separation is far easier to secure and maintain than trying to hide and display complex logic within one monolithic panel. If you are leveraging Laravel's strong foundation for building applications on **https://laravelcompany.com**, adopting this modular structure will pay massive dividends in long-term development velocity.
## Conclusion
While hiding UI elements directly is possible, it often leads to brittle code when dealing with complex authorization logic. For separating Admin and User interfaces in Filament, the recommended path is architectural separation: create distinct panels for each user type. This provides clarity, enhances security by default, and adheres to the principle of separation of concerns. Always rely on Laravel's robust authorization system (Policies) to govern access, ensuring your application remains secure and scalable.