Advanced Features
Complex Aggregate Filtering
Build sophisticated aggregate conditions using the visual filter builder:
Filter Groups
Create multiple filter groups with AND/OR logic:
- Group filters logically
- Nest conditions within groups
- Visual organization with operator display
Relationship Filters in Aggregates
Filter aggregates based on related model conditions:
COUNT(orders) WHERE orders.status = 'completed'
AND orders.customer.country = 'US'
Through Relationships
Data Lens provides optimized support for HasOneThrough and HasManyThrough relationships.
Performance Optimization
// config/data-lens.php
'through_relationships' => [
'max_depth' => 3, // Maximum chain depth
'performance_threshold_ms' => 1000, // Log slow queries
'auto_index_suggestion' => true, // Suggest indexes
'optimize_queries' => true, // Enable optimizations
],
Automatic Index Suggestions
When enabled, Data Lens logs index recommendations:
[Data Lens] Suggested index: orders (customer_id, created_at)
Cache Management
Intelligent Caching
Data Lens caches expensive operations:
- Model introspection results
- Relationship metadata
- Filter type detection
- Through relationship chains
Multi-Tenant Cache Isolation
📖 For complete multi-tenant setup, see the Multi-Tenant Setup Guide
Automatic cache isolation per tenant prevents data leakage:
// config/data-lens.php
'cache' => [
'tenant_resolver' => function () {
return auth()->user()?->company_id;
},
],
Cache Clearing Strategies
# Clear all cache
php artisan data-lens:clear-cache
# Clear specific type
php artisan data-lens:clear-cache --type=model_fields
# In deployment scripts
php artisan data-lens:clear-cache --force
Column Type Detection
Data Lens automatically detects appropriate column types based on patterns:
Money Fields
Automatically formatted when field names contain:
- price, cost, amount, balance
- fee, payment, salary, total
- budget, revenue, income, expense, tax
Boolean Fields
Automatically rendered as badges when field names:
- Start with: is_, has_, can_, should_
- Contain: active, enabled, approved
Custom Patterns
// config/data-lens.php
'column_type_detection' => [
'money_field_patterns' => ['custom_price_field'],
'boolean_field_patterns' => ['custom_flag'],
],
Advanced Formatting
Badge Columns
Use the visual formatting interface to create badge columns:
- Select badge style in the format configuration modal
- Choose colors based on field values (success, warning, danger, etc.)
- Configure color mappings for different states
Custom Icons
Add Heroicons to enhance visual communication:
- Position before or after text
- Independent color configuration
- Full Heroicon library support
HTML Content
Safely render HTML content:
- Automatic sanitization
- Preserves safe formatting
- Prevents XSS attacks
API Advanced Usage
IP Whitelisting
Restrict API access to specific IPs (global configuration):
// Enable API per panel
DataLensPlugin::make()
->apiEnabled()
// Configure IP whitelist globally in config/data-lens.php
'api' => [
'ip_whitelist' => [
'192.168.1.0/24', // Subnet
'10.0.0.50', // Single IP
],
],
Scheduling Advanced Features
Complex Recurrence Rules
Data Lens uses RFC 5545 compliant RRULE for complex schedules:
- Every weekday at 9 AM
- First and third Monday of each month
- Last Friday of each quarter
- Custom RRULE strings
Timezone Handling
Configure timezone resolution for your application:
// In AppServiceProvider boot method
use Padmission\DataLens\DataLens;
DataLens::setTimezoneResolver(function () {
return auth()->user()?->timezone ?? config('app.timezone');
});
Email Customization
Create custom mail classes for advanced features:
class TenantAwareReportEmail extends ReportEmail
{
public function build()
{
// Add tenant-specific headers
$this->withSymfonyMessage(function ($message) {
$message->getHeaders()->addTextHeader(
'X-Tenant-ID',
$this->schedule->customReport->tenant_id
);
});
return parent::build();
}
}
Export Optimizations
Chunked Processing
Configure chunk size globally for large exports:
// In config/data-lens.php
'exports' => [
'chunk_size' => 5000, // Process 5000 rows at a time
],
Memory Management
Exports use streaming to minimize memory usage:
- Processes data in chunks
- Streams directly to file
- Automatic garbage collection
Security Features
Column Security
Automatically exclude sensitive columns:
php artisan data-lens:suggest-excluded-columns --format=config
Output categorized by risk level:
- HIGH: Passwords, tokens, keys
- MEDIUM: Personal info, financial data
- LOW: Tracking, configuration
Model Exclusions
Prevent entire models from appearing in reports:
'excluded_models' => [
\App\Models\AdminUser::class,
\App\Models\SystemConfig::class,
],
Performance Monitoring
Query Performance Tracking
Log slow queries for optimization:
'through_relationships' => [
'performance_threshold_ms' => 500, // Log queries over 500ms
],
Export Performance
Monitor export processing times:
- Tracked in schedule history
- Available via API metadata
- Logged for analysis
Integration Features
Data Lens integrates with popular Filament packages:
'integrations' => [
'custom_fields' => true, // Relaticle Custom Fields
'advanced_tables' => true, // Advanced Tables
],
Custom Fields
- Rich field types (text, select, date, file upload, etc.)
- Multi-tenancy field configuration
- Built-in validation framework
Advanced Tables
- User-customizable saved views
- Advanced filter builder
- Column reordering and persistence
Debugging Tools
Debug Mode
Enable detailed logging:
php artisan data-lens:check-scheduled-reports --debug
Cache Inspection
View cache contents for debugging:
// In tinker or debug code
app(\Padmission\DataLens\Services\CacheManager::class)
->getCacheKey('model_fields', 'App\Models\User');