PHP code example of visual1 / statamic-font-awesome-fieldtype

1. Go to this page and download the library: Download visual1/statamic-font-awesome-fieldtype library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

visual1 / statamic-font-awesome-fieldtype example snippets


// In a service provider
$this->app['events']->listen('fontawesome.icons.loading', function ($query) {
    // Add custom icons to search results
    return array_merge($query->icons, $customIcons);
});

// config/fontawesome.php
return [
    'cache_duration' => 3600, // 1 hour instead of 30 minutes
    'search_cache_duration' => 1800, // 30 minutes instead of 10
    'max_search_results' => 50, // Reduce from 100 for faster loading
];

// Get augmented icon data
$iconData = $entry->augmentedValue('my_icon');

// Check if field has value
$hasIcon = $fieldtype->hasValue($value);

// Process field data
$processed = $fieldtype->process($data);
bash
php artisan vendor:publish --tag=fontawesome-config
bash
# Clear Statamic cache
php artisan cache:clear

# Clear compiled views
php artisan view:clear