Helper Functions
Introduction
Fluent Community provides a comprehensive Helper class with utility functions that make it easier to work with the plugin. These helper functions cover common tasks like portal configuration, user management, space operations, media handling, and more.
TIP
The Helper class is located at FluentCommunity\App\Functions\Utility::class and provides static methods that can be called from anywhere in your code.
Accessing the Helper Class
You can access the Helper class methods using the following syntax:
php
use FluentCommunity\App\Functions\Utility;
// Example: Get the portal slug
$portalSlug = Utility::getPortalSlug();
// Example: Check if user is site admin
$isAdmin = Utility::isSiteAdmin($userId);Available Helper Methods
The Helper class provides the following categories of utility functions:
Portal Configuration
- getPortalSlug() - Get the portal URL slug
- getPortalRouteType() - Get the portal route type
- isHeadless() - Check if portal is in headless mode
- hasColorScheme() - Check for color scheme support
- baseUrl() - Generate portal base URL
User & Profile Management
- getCurrentProfile() - Get current user's profile
- getCurrentUser() - Get current user model
- isSiteAdmin() - Check if user is site admin
Space Management
- addToSpace() - Add user to a space
- removeFromSpace() - Remove user from a space
Menu & Navigation
- getMenuItemsGroup() - Get menu items group
Media Handling
- getMediaFromUrl() - Get media object from URL
Security & Utilities
- encryptDecrypt() - Encrypt or decrypt values
- getIp() - Get user's IP address
Next Steps
- Explore the Helper Class Reference for detailed documentation of each method
- Check out Code Snippets for practical examples
- Learn about Database Models for working with data
