src/ServiceProvider.php
private function registerBladeDirectives()
    {
        // Start capturing.
        if (!$this->app['config']->has('hnhdigital.blade.disable.capture')) {
            blade::directive('capture', function () {
                return '<?php ob_start(); ?>';
            });

            // Stop capturing.
            blade::directive('endcapture', function ($name) {
                if (substr($name, 0, 1) == '$') {
                    $name = substr($text, 1);
                }
                $name = trim($name, "'\"");

                return '<?php $'.$name.' = ob_get_clean(); ?>';
            });
        }

        // Call.
        if (!$this->app['config']->has('hnhdigital.blade.disable.call')) {
            blade::directive('call', function ($call) {
                $name = trim($name, "'\"");

                return "<?php $call; ?>";
            });
        }

        // CSRF.
        // @todo Remove when dropping L5.5 support.
        if (!$this->app['config']->has('hnhdigital.blade.disable.csrf')) {
            blade::directive('csrf', function () {
                return '<?= csrf_field(); ?>';
            });
        }

        // Single line of php
        if (!$this->app['config']->has('hnhdigital.blade.disable.raw')) {
            blade::directive('raw', function ($raw) {
                return "<?php $raw; ?>";
            });
        }

        // Multiple lines of php.
        if (!$this->app['config']->has('hnhdigital.blade.disable.php')) {
            blade::directive('php', function ($raw) {
                return "<?php\n$raw\n?>";
            });
        }

        // Share with view.
        if (!$this->app['config']->has('hnhdigital.blade.disable.share')) {
            blade::directive('share', function ($share) {
                return "<?php view()->share($share); ?>";
            });
        }

        // Use.
        if (!$this->app['config']->has('hnhdigital.blade.disable.use')) {
            blade::directive('use', function ($use) {
                return "<?php use $use; ?>";
            });
        }

        // Route.
        blade::directive('route', function ($use) {
            return "<?= route($use) ?>";
        });

        if (!$this->app['config']->has('hnhdigital.blade.disable.locale')) {
            // Format number.
            blade::directive('locale_currency_symbol', function () {
                return '<?= locale_currency_symbol() ?>';
            });

            // Format number.
            blade::directive('locale_format_number', function ($args) {
                return "<?= locale_format_number($args) ?>";
            });

            // Format currency.
            blade::directive('float_format_currency', function ($args) {
                return "<?= float_format_currency($args) ?>";
            });
        }

        if (!$this->app['config']->has('hnhdigital.blade.disable.datetime')) {
            // Format date using user format and timezone.
            blade::directive('user_timedate', function ($args) {
                return "<?= user_timedate($args) ?>";
            });

            // Format date using user format and timezone.
            blade::directive('user_time', function ($args) {
                return "<?= user_time($args) ?>";
            });

            // Format date using user format and timezone.
            blade::directive('user_date', function ($args) {
                return "<?= user_date($args) ?>";
            });
        }

        // Various text helper directives.
        if (!$this->app['config']->has('hnhdigital.blade.disable.text')) {
            foreach (['__', 'camel_case', 'kebab_case', 'snake_case', 'studly_case', 'str_plural', 'str_tense', 'title_case'] as $function_name) {
                blade::directive($function_name, function ($text) use ($function_name) {
                    $text = implode(',', array_map(function ($value) {
                        $value = trim($value, "'\" ");
                        if (substr($value, 0, 1) !== '$') {
                            $value = "'$value'";
                        }

                        return $value;
                    }, explode(',', $text)));

                    return "<?= $function_name($text); ?>";
                });
            }

            // @str_upper => strtoupper
            blade::directive('str_upper', function ($text) use ($function_name) {
                if (substr($text, 0, 1) !== '$') {
                    $text = "'$text'";
                }

                return "<?= strtoupper($text); ?>";
            });

            // @str_lower => strtolower
            blade::directive('str_lower', function ($text) use ($function_name) {
                if (substr($text, 0, 1) !== '$') {
                    $text = "'$text'";
                }

                return "<?= strtolower($text); ?>";
            });
        }
    }
private function registerBladeDirectives()
    {
        // Start capturing.
        if (!$this->app['config']->has('hnhdigital.blade.disable.capture')) {
            blade::directive('capture', function () {
                return '<?php ob_start(); ?>';
            });

            // Stop capturing.
            blade::directive('endcapture', function ($name) {
                if (substr($name, 0, 1) == '$') {
                    $name = substr($text, 1);
                }
                $name = trim($name, "'\"");

                return '<?php $'.$name.' = ob_get_clean(); ?>';
            });
        }

        // Call.
        if (!$this->app['config']->has('hnhdigital.blade.disable.call')) {
            blade::directive('call', function ($call) {
                $name = trim($name, "'\"");

                return "<?php $call; ?>";
            });
        }

        // CSRF.
        // @todo Remove when dropping L5.5 support.
        if (!$this->app['config']->has('hnhdigital.blade.disable.csrf')) {
            blade::directive('csrf', function () {
                return '<?= csrf_field(); ?>';
            });
        }

        // Single line of php
        if (!$this->app['config']->has('hnhdigital.blade.disable.raw')) {
            blade::directive('raw', function ($raw) {
                return "<?php $raw; ?>";
            });
        }

        // Multiple lines of php.
        if (!$this->app['config']->has('hnhdigital.blade.disable.php')) {
            blade::directive('php', function ($raw) {
                return "<?php\n$raw\n?>";
            });
        }

        // Share with view.
        if (!$this->app['config']->has('hnhdigital.blade.disable.share')) {
            blade::directive('share', function ($share) {
                return "<?php view()->share($share); ?>";
            });
        }

        // Use.
        if (!$this->app['config']->has('hnhdigital.blade.disable.use')) {
            blade::directive('use', function ($use) {
                return "<?php use $use; ?>";
            });
        }

        // Route.
        blade::directive('route', function ($use) {
            return "<?= route($use) ?>";
        });

        if (!$this->app['config']->has('hnhdigital.blade.disable.locale')) {
            // Format number.
            blade::directive('locale_currency_symbol', function () {
                return '<?= locale_currency_symbol() ?>';
            });

            // Format number.
            blade::directive('locale_format_number', function ($args) {
                return "<?= locale_format_number($args) ?>";
            });

            // Format currency.
            blade::directive('float_format_currency', function ($args) {
                return "<?= float_format_currency($args) ?>";
            });
        }

        if (!$this->app['config']->has('hnhdigital.blade.disable.datetime')) {
            // Format date using user format and timezone.
            blade::directive('user_timedate', function ($args) {
                return "<?= user_timedate($args) ?>";
            });

            // Format date using user format and timezone.
            blade::directive('user_time', function ($args) {
                return "<?= user_time($args) ?>";
            });

            // Format date using user format and timezone.
            blade::directive('user_date', function ($args) {
                return "<?= user_date($args) ?>";
            });
        }

        // Various text helper directives.
        if (!$this->app['config']->has('hnhdigital.blade.disable.text')) {
            foreach (['__', 'camel_case', 'kebab_case', 'snake_case', 'studly_case', 'str_plural', 'str_tense', 'title_case'] as $function_name) {
                blade::directive($function_name, function ($text) use ($function_name) {
                    $text = implode(',', array_map(function ($value) {
                        $value = trim($value, "'\" ");
                        if (substr($value, 0, 1) !== '$') {
                            $value = "'$value'";
                        }

                        return $value;
                    }, explode(',', $text)));

                    return "<?= $function_name($text); ?>";
                });
            }

            // @str_upper => strtoupper
            blade::directive('str_upper', function ($text) use ($function_name) {
                if (substr($text, 0, 1) !== '$') {
                    $text = "'$text'";
                }

                return "<?= strtoupper($text); ?>";
            });

            // @str_lower => strtolower
            blade::directive('str_lower', function ($text) use ($function_name) {
                if (substr($text, 0, 1) !== '$') {
                    $text = "'$text'";
                }

                return "<?= strtolower($text); ?>";
            });
        }
    }
Register blade directives.

@return void