PHP code example of bhuvidya / laravel-blade-helper

1. Go to this page and download the library: Download bhuvidya/laravel-blade-helper 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/ */

    

bhuvidya / laravel-blade-helper example snippets


// Define the helper directive
BladeHelper::helper('example', function($a, $b, $c = 'give', $d = 'you') {
    return "$a $b $c $d up";
});

// Use it in a view
@example('Never', 'gonna')

// Get the compiled result
 echo \Illuminate\Support\Facades\Blade::getHelper('example', 'Never', 'gonna'); 

BladeHelper::helper('fa', function(string $iconName, string $text = null, $classes = '') {
    if (is_array($classes)) {
        $classes = join(' ', $classes);
    }

    $text = $text ?? $iconName;

    return "<i class='fa fa-{$iconName} {$classes}' aria-hidden='true' title='{$text}'></i><span class='sr-only'>{$text}</span>";
});