Resources Documentation
This document provides a comprehensive overview of all available Filament resources in the Filament Tenancy package.
Overview
Section titled “Overview”The package provides separate resource sets for:
- Landlord/Admin Panel - Full management capabilities
- Tenant Panel - Limited, tenant-specific functionality
Landlord Resources
Section titled “Landlord Resources”🏢 Tenant Management
Section titled “🏢 Tenant Management”TenantResource
Section titled “TenantResource”Full tenant management with CRUD operations, domain configuration, and database settings.
Features:
- Complete tenant lifecycle management
- Domain/subdomain configuration
- Database connection settings
- Status management
- Bulk operations
Navigation: Tenants (root level)
💳 Billing Management
Section titled “💳 Billing Management”PlanResource
Section titled “PlanResource”Manage subscription plans available to tenants.
Features:
- Plan creation and configuration
- Pricing and billing cycle setup
- Feature and limits management
- Popular/featured plan designation
- Color coding for UI elements
Navigation: Billing Management → Plans
SubscriptionResource
Section titled “SubscriptionResource”Manage tenant subscriptions and billing.
Features:
- Subscription lifecycle management
- Status tracking (active, cancelled, expired, etc.)
- Auto-renewal settings
- Payment method tracking
- Trial period management
- Expiration monitoring
Navigation: Billing Management → Subscriptions
👥 User Management
Section titled “👥 User Management”RoleResource
Section titled “RoleResource”Manage roles and their permissions.
Features:
- Role creation and assignment
- Permission management
- User assignment tracking
- Color-coded roles
- Bulk role operations
Navigation: User Management → Roles
PermissionResource
Section titled “PermissionResource”Manage system permissions.
Features:
- Permission creation and grouping
- System permission protection
- Role assignment tracking
- User assignment tracking
- Permission categorization
Navigation: User Management → Permissions
Tenant Resources
Section titled “Tenant Resources”💳 Billing
Section titled “💳 Billing”Tenant\PlanResource
Section titled “Tenant\PlanResource”View available subscription plans and manage subscriptions.
Features:
- Browse available plans (read-only)
- View plan details and features
- Subscribe to plans
- Current subscription status widget
- Pricing comparison
Navigation: Billing → Plans
Restrictions:
- Cannot create/edit plans
- Can only view available plans
- Can subscribe to plans
👥 User Management
Section titled “👥 User Management”Tenant\RoleResource
Section titled “Tenant\RoleResource”Manage tenant-specific roles and permissions.
Features:
- Role creation and management
- Permission assignment
- User role assignment
- Role-based access control
Navigation: User Management → Roles
Scope:
- Only shows roles for current tenant
- Only shows users for current tenant
- Tenant-isolated permissions
Resource Features
Section titled “Resource Features”Common Features
Section titled “Common Features”All resources include:
- Auto-generated slugs from names
- Live validation
- Color pickers for visual elements
- Rich text descriptions
- Key-value metadata fields
Tables
Section titled “Tables”- Searchable columns
- Sortable fields
- Advanced filtering
- Bulk actions
- Export capabilities
Actions
Section titled “Actions”- View, Edit, Delete operations
- Custom actions (e.g., Subscribe, Cancel)
- Confirmation dialogs
- Success/error notifications
Infolists
Section titled “Infolists”- Detailed record views
- Badge displays for status
- Color-coded elements
- Timestamp tracking
- Relationship displays
Advanced Features
Section titled “Advanced Features”Tenant Isolation
Section titled “Tenant Isolation”- Automatic tenant context switching
- Tenant-scoped queries
- Secure data separation
- Cross-tenant prevention
Permission Integration
Section titled “Permission Integration”- Role-based access control
- Permission checking
- Secure operations
- Audit trails
Status Management
Section titled “Status Management”- Visual status indicators
- State-based actions
- Workflow controls
- Status transitions
Navigation Structure
Section titled “Navigation Structure”Landlord Panel
Section titled “Landlord Panel”📋 Dashboard├── 🏢 Tenants├── 💳 Billing Management│ ├── 💳 Plans│ └── 📄 Subscriptions└── 👥 User Management ├── 🛡️ Roles └── 🔑 PermissionsTenant Panel
Section titled “Tenant Panel”📋 Dashboard├── 💳 Billing│ └── 💳 Plans└── 👥 User Management └── 🛡️ RolesUsage Examples
Section titled “Usage Examples”Creating a Plan
Section titled “Creating a Plan”// Via Filament Admin Panel1. Navigate to Billing Management → Plans2. Click "New Plan"3. Fill in plan details: - Name: "Professional" - Price: 29.99 - Billing Cycle: "monthly" - Features: ["API Access", "Priority Support"]4. Save planManaging Subscriptions
Section titled “Managing Subscriptions”// Via Filament Admin Panel1. Navigate to Billing Management → Subscriptions2. View active subscriptions3. Use actions: - Cancel subscription - Reactivate expired - Update payment methodTenant Role Management
Section titled “Tenant Role Management”// Via Tenant Panel1. Navigate to User Management → Roles2. Create new role: "Content Manager"3. Assign permissions: ["create_posts", "edit_posts"]4. Assign to usersCustomization
Section titled “Customization”Extending Resources
Section titled “Extending Resources”// Custom tenant resourceclass CustomTenantResource extends Resource{ protected static ?string $model = CustomModel::class;
public static function form(Form $form): Form { return $form->schema([ // Custom form fields ]); }}Adding Custom Actions
Section titled “Adding Custom Actions”// Add custom action to existing resourcepublic static function table(Table $table): Table{ return $table->actions([ Tables\Actions\Action::make('custom_action') ->label('Custom Action') ->action(function ($record) { // Custom logic }), ]);}Custom Filters
Section titled “Custom Filters”// Add custom filterpublic static function table(Table $table): Table{ return $table->filters([ Tables\Actions\Filter::make('custom_filter') ->query(fn ($query) => $query->where('field', 'value')) ->label('Custom Filter'), ]);}Security Considerations
Section titled “Security Considerations”Tenant Isolation
Section titled “Tenant Isolation”- All tenant resources are automatically scoped
- Cross-tenant data access is prevented
- Database connections are tenant-specific
Permission Checks
Section titled “Permission Checks”- All operations require appropriate permissions
- System permissions are protected
- Role-based access control is enforced
Data Validation
Section titled “Data Validation”- Input validation on all forms
- Sanitization of user data
- Protection against injection attacks
Best Practices
Section titled “Best Practices”Resource Organization
Section titled “Resource Organization”- Group related resources logically
- Use consistent naming conventions
- Implement proper navigation hierarchy
Performance Optimization
Section titled “Performance Optimization”- Use efficient queries with relationships
- Implement proper indexing
- Cache frequently accessed data
User Experience
Section titled “User Experience”- Provide clear labels and descriptions
- Use appropriate visual indicators
- Implement intuitive workflows
Security
Section titled “Security”- Always validate user input
- Implement proper permission checks
- Use tenant-scoped queries
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Resources Not Showing
Section titled “Resources Not Showing”- Check plugin registration
- Verify resource class imports
- Ensure proper namespace usage
Permission Errors
Section titled “Permission Errors”- Verify role assignments
- Check permission definitions
- Ensure tenant context is active
Data Not Isolated
Section titled “Data Not Isolated”- Check model traits
- Verify tenant middleware
- Ensure proper database connections
Debug Tips
Section titled “Debug Tips”-
Check Resource Registration
// Verify resources are registeredfilament()->getResources() -
Check Permissions
// Verify user permissionsauth()->user()->hasPermissionTo('permission_name') -
Check Tenant Context
// Verify tenant is activetenancy()->current()
Integration Examples
Section titled “Integration Examples”Custom Widgets
Section titled “Custom Widgets”class SubscriptionStatsWidget extends Widget{ protected static string $view = 'widgets.subscription-stats';
protected function getData(): array { return [ 'active_subscriptions' => Subscription::where('status', 'active')->count(), 'revenue' => Subscription::sum('price'), ]; }}Custom Pages
Section titled “Custom Pages”class BillingOverviewPage extends Page{ protected static string $view = 'filament.pages.billing-overview';
protected static ?string $navigationIcon = 'heroicon-o-chart-bar';
protected static ?string $navigationLabel = 'Billing Overview';
public function mount(): void { // Custom initialization }}Custom Actions
Section titled “Custom Actions”public static function table(Table $table): Table{ return $table->actions([ Tables\Actions\Action::make('upgrade_plan') ->label('Upgrade') ->color('success') ->action(function ($record) { // Upgrade subscription logic $record->upgradeToNextPlan(); }) ->visible(fn ($record) => $record->canUpgrade()), ]);}This documentation provides a comprehensive guide to all available resources and their capabilities. For more specific implementation details, refer to the individual resource files and their method documentation.