protected function registerDirectives()
    {
        if (version_compare($this->app->version(), '5.5', '>=')) {
            // Workaround to support the PHP5.6 syntax.
            // Even tho the laravel version will lock to 7.0 >=
            // but the code is still complied and throws syntax error on 5.6.
            $blade = Blade::getFacadeRoot();
            $if    = 'if';

            foreach (['desktop', 'tablet', 'mobile'] as $key) {
                $blade->$if($key, function () use ($key) {
                    $fn = 'is' . $key;
                    return app()->make('browser-detect')->detect()->$fn();
                });
            }

            $blade->$if('browser', function ($fn) {
                return app()->make('browser-detect')->detect()->$fn();
            });
        }
    }
protected function registerDirectives()
    {
        if (version_compare($this->app->version(), '5.5', '>=')) {
            // Workaround to support the PHP5.6 syntax.
            // Even tho the laravel version will lock to 7.0 >=
            // but the code is still complied and throws syntax error on 5.6.
            $blade = Blade::getFacadeRoot();
            $if    = 'if';

            foreach (['desktop', 'tablet', 'mobile'] as $key) {
                $blade->$if($key, function () use ($key) {
                    $fn = 'is' . $key;
                    return app()->make('browser-detect')->detect()->$fn();
                });
            }

            $blade->$if('browser', function ($fn) {
                return app()->make('browser-detect')->detect()->$fn();
            });
        }
    }
protected function registerDirectives ( ) { if ( version_compare ( $ this -> app -> version ( ) , '5.5' , '>=' ) ) { // Workaround to support the PHP5.6 syntax. // Even tho the laravel version will lock to 7.0 >= // but the code is still complied and throws syntax error on 5.6. $ blade = Blade :: getFacadeRoot ( ) ; $ if = 'if' ; foreach ( [ 'desktop' , 'tablet' , 'mobile' ] as $ key ) { $ blade -> $ if ( $ key , function ( ) use ( $ key ) { $ fn = 'is' . $ key ; return app ( ) -> make ( 'browser-detect' ) -> detect ( ) -> $ fn ( ) ; } ) ; } $ blade -> $ if ( 'browser' , function ( $ fn ) { return app ( ) -> make ( 'browser-detect' ) -> detect ( ) -> $ fn ( ) ; } ) ; } }
Register the blade directives.
Register the blade directives .