예제 #1
0
 private function registerDirectives()
 {
     Blade::directive('allowed', function ($expression) {
         if (Str::startsWith($expression, '(')) {
             $expression = substr($expression, 1, -1);
         }
         return "<?php if (app('rbac')->checkAccess(\\Auth::user(), {$expression})): ?>";
     });
     if (Config::get('rbac.shortDirectives')) {
         foreach (Rbac::getRepository() as $name => $item) {
             $directiveName = $item->type == Item::TYPE_PERMISSION ? 'allowed' : 'is';
             $directiveName .= Str::studly(str_replace('.', ' ', $name));
             Blade::directive($directiveName, function ($expression) use($name) {
                 $expression = trim($expression, '()');
                 if (!empty($expression)) {
                     $expression = ', ' . $expression;
                 }
                 return "<?php if (app('rbac')->checkAccess(\\Auth::user(), '{$name}'{$expression})): ?>";
             });
         }
     }
     Blade::directive('endallowed', function ($expression) {
         return "<?php endif; ?>";
     });
 }
예제 #2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     Blade::directive('dump', function ($data) {
         return sprintf("<?php (new Illuminate\\Support\\Debug\\Dumper)->dump(%s); ?>", null !== $data ? $data : "get_defined_vars()['__data']");
     });
 }
 /**
  * Register blade directives.
  */
 protected function registerBladeDirectives()
 {
     Blade::directive('form', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php app('sahib_form')->model{$expression}; ?>";
     });
     Blade::directive('input', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php echo app('sahib_form')->input{$expression}; ?>";
     });
     Blade::directive('text', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php echo app('sahib_form')->text{$expression}; ?>";
     });
     Blade::directive('checkbox', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php echo app('sahib_form')->checkbox{$expression}; ?>";
     });
     Blade::directive('radio', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php echo app('sahib_form')->radio{$expression}; ?>";
     });
     Blade::directive('options', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php echo app('sahib_form')->options{$expression}; ?>";
     });
     Blade::directive('error', function ($expression) {
         $expression = $this->addParenthesis($expression);
         return "<?php echo app('sahib_form')->error{$expression}; ?>";
     });
 }
 public function boot()
 {
     $this->publishes([__DIR__ . DIRECTORY_SEPARATOR . 'config.php' => config_path('russian.php')]);
     Blade::directive('russian', function ($expression) {
         $className = RussianDollCaching::class;
         return "<?php echo app('{$className}')->get{$expression}; ?>";
     });
 }
예제 #5
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     // Formats a string using the specified date pattern
     // Usage: @datetime($expression)
     Blade::directive('datetime', function ($expression) {
         return "<?= with{$expression}->format('F d, Y, h:m A'); ?>";
     });
 }
 public function boot()
 {
     $this->publishes([__DIR__ . '/../config/laravel-blade-javascript.php' => config_path('laravel-blade-javascript.php')], 'config');
     Blade::directive('javascript', function ($expression) {
         $expression = $this->makeBackwardsCompatible($expression);
         return "<?= app('\\Spatie\\BladeJavaScript\\Renderer')->render{$expression}; ?>";
     });
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->publishes([__DIR__ . '/../config/columnsortable.php' => config_path('columnsortable.php')], 'config');
     Blade::directive('sortablelink', function ($expression) {
         $expression = $expression[0] === '(' ? substr($expression, 1, -1) : $expression;
         return "<?php echo \\Kyslik\\ColumnSortable\\SortableLink::render(array ({$expression}));?>";
     });
 }
 protected function bootBladeDirective()
 {
     Blade::directive('block', function ($expression) {
         return "<?php if (! Dyusha\\HtmlEditor\\HtmlBlocks::setUp({$expression})) { ?>";
     });
     Blade::directive('endblock', function () {
         return "<?php } echo Dyusha\\HtmlEditor\\HtmlBlocks::tearDown() ?>";
     });
 }
예제 #9
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Blade::directive('cache', function ($expression) {
         return "<?php if (! app('SteveAzz\\RuDolly\\BladeDirective')->setUp{$expression}) : ?>";
     });
     Blade::directive('endcache', function () {
         return "<?php endif; echo app('SteveAzz\\RuDolly\\BladeDirective')->tearDown() ?>";
     });
 }
예제 #10
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     array_walk($this->statements, function ($statement) {
         Blade::directive($statement, function ($expression) use($statement) {
             $method = 'compile' . ucfirst($statement);
             return $this->{$method}($expression);
         });
     });
 }
예제 #11
0
 protected function registerBlade()
 {
     Blade::directive('role', function ($expression) {
         return "<?php if(auth()->check() && auth()->user()->hasRole({$expression})): ?>";
     });
     Blade::directive('endrole', function () {
         return "<?php endif; ?>";
     });
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Blade::directive('Perm', function ($permission) {
         return '<?php if((Auth::check()&&\\App\\Permission::permission(' . $permission . ', Auth::user()->id))||(!Auth::check()&&\\App\\Permission::guest(' . $permission . '))): ?>';
     });
     Blade::directive('endPerm', function () {
         return '<?php endif; ?>';
     });
 }
예제 #13
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Blade::directive('cache', function ($expresion) {
         return "<?php if( ! app('Sargilla\\Mamushka\\BladeDirective')->setUp{$expresion} ) {  ?>";
     });
     Blade::directive('endcache', function () {
         return "<?php } echo app('Sargilla\\Mamushka\\BladeDirective')->tearDown() ?>";
     });
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Blade::directive('break', function () {
         return "<?php break; ?>";
     });
     Blade::directive('continue', function () {
         return "<?php continue; ?>";
     });
 }
예제 #15
0
 public function boot()
 {
     Blade::directive('gravatar', function () {
         return '<?="http://www.gravatar.com/avatar/" . md5( strtolower( trim( $user->email ) ) ) . "?d=mm";?>';
     });
     Blade::directive('csrf', function () {
         return '<?="<input type=\\"hidden\\" name=\\"_token\\" value=\\"".csrf_token()."\\">";?>';
     });
 }
예제 #16
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->publishes([__DIR__ . '/config/tabmenu.php' => config_path('tabmenu.php')]);
     Blade::directive('menu', function () {
         return "<?= app('DNABeast/TabMenu/TabMenu')->build('";
     });
     Blade::directive('endmenu', function () {
         return "');?>";
     });
 }
예제 #17
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Factory $validator)
 {
     require_once app_path() . '/validators.php';
     Blade::directive('role', function ($expression) {
         return "<?php if(Auth::check() && Auth::user()->hasRole{$expression}): ?>";
     });
     Blade::directive('endrole', function ($expression) {
         return "<?php endif ?>";
     });
 }
예제 #18
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     /**
      * Custom Blade directive for checking when a Harvest was last run
      * and returning a formatted string.
      */
     Blade::directive('lastrundiff', function ($lastRunAt) {
         return "<?php echo '<span title=\"' . with{$lastRunAt}->format('D, M j, Y g:i:s a') . '\">' . with{$lastRunAt}->diffForHumans() . '</span>'; ?>";
     });
 }
예제 #19
0
 /**
  * Register the Blade directive for Blocks.
  */
 protected function registerBlockBladeDirective()
 {
     Blade::directive('block', function ($expression) {
         $expression = $this->sanitizeExpression($expression);
         list($module, $component) = explode('::', $expression);
         if (view()->exists("{$module}::blocks.{$component}")) {
             return "<?php echo \$__env->make('{$module}::blocks.{$component}', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
         }
     });
 }
예제 #20
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Kernel $kernel)
 {
     Blade::directive('cache', function ($expression) {
         return "<?php if(! app('JoeriAben\\BladeCache\\Tags')->open{$expression}): ?>";
     });
     Blade::directive('endcache', function () {
         return "<?php endif; echo app('JoeriAben\\BladeCache\\Tags')->close() ?>";
     });
     $this->publishes([__DIR__ . '/../config/bladecache.php' => $this->app->configPath() . '/' . 'bladecache.php'], 'config');
     $kernel->pushMiddleware('JoeriAben\\BladeCache\\Middleware');
 }
 /**
  * Registers the closing directives
  * @return void
  */
 protected function registerClosingDirectives()
 {
     Blade::directive('endrole', function () {
         return "<?php endif; // app('laratrust')->hasRole ?>";
     });
     Blade::directive('endpermission', function () {
         return "<?php endif; // app('laratrust')->can ?>";
     });
     Blade::directive('endability', function () {
         return "<?php endif; // app('laratrust')->ability ?>";
     });
 }
 /**
  * Register meta blade extensions .
  *
  */
 protected function registerBladeExtension()
 {
     if ($this->versionMatch('5.0')) {
         Blade::extend(function ($view) {
             return str_replace("@meta", app('meta')->render(), $view);
         });
     } elseif ($this->versionMatch('5.1')) {
         Blade::directive('meta', function ($expression) {
             return app('meta')->render($expression);
         });
     }
 }
예제 #23
0
 protected function extendBlade()
 {
     Blade::directive('component', function ($params) {
         list($view, $vars) = $this->extractComponentParams($params);
         return "<?php echo \$__env->make('{$view}', {$vars})->render(); ?>";
     });
     Blade::directive('startcomponent', function ($params) {
         list($view, $vars) = $this->extractComponentParams($params);
         return "<?php ob_start(); \$_c_name='{$view}'; \$_c_data={$vars}; ?>";
     });
     Blade::directive('endcomponent', function () {
         return "<?php echo \$__env->make(\$_c_name, array_merge(\$_c_data, ['slot' => ob_get_clean()]))->render(); ?>";
     });
 }
예제 #24
0
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     // blade extens date indo
     Blade::directive('thunder_mail_date_indo', function ($expression) {
         return "<?php echo date('d-m-Y H:i', strtotime({$expression})); ?>";
     });
     // blade extens money indonesia
     Blade::directive('thunder_mail_money_indo', function ($expression) {
         return "<?php echo 'IDR '.number_format({$expression}, 0, ',', '.'); ?>";
     });
     // blade extens money indonesia for email
     Blade::directive('thunder_mail_money_indo_without_IDR', function ($expression) {
         return "<?php echo number_format({$expression}, 0, ',', '.'); ?>";
     });
 }
 /**
  * Bootstrap the application services.
  * @return void
  */
 public function boot()
 {
     Blade::directive('HelpDoc', function ($expression) {
         $path = $this->sanitizeExpression($expression);
         return "<?php echo \\GrahamCampbell\\Markdown\\Facades\\Markdown::convertToHtml(file_get_contents(base_path('resources/help_docs/' . str_replace('.', '/', {$path}) . '.md'))); ?>";
     });
     Blade::directive('InputClass', function ($name) {
         $name = $this->sanitizeExpression($name);
         return "<?php echo \$errors->any() ? (\$errors->default->has({$name}) ? 'has-error' : 'has-success') : ''; ?>";
     });
     Blade::directive('InputError', function ($name) {
         $name = $this->sanitizeExpression($name);
         return "<?php echo \$errors->any() && \$errors->default->has({$name}) ? ('<p class=\"help-block\">' . \$errors->default->first({$name}) . '</p>') : ''; ?>";
     });
 }
 /**
  * Register any misc. blade extensions
  */
 public function register()
 {
     /**
      * The block of code inside this directive indicates
      * the chosen language requests RTL support.
      */
     Blade::directive('langRTL', function () {
         return "<?php if (session()->has('lang-rtl')): ?>";
     });
     /**
      * Sets a PHP variable in a blade view
      * Courtesy of https://github.com/sineld/bladeset
      */
     Blade::extend(function ($value) {
         return preg_replace("/@set\\(['\"](.*?)['\"]\\,(.*)\\)/", '<?php $$1 = $2; ?>', $value);
     });
 }
예제 #27
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $visitor = new Visitor();
     $visitor->checkVisitor();
     $this->app->singleton('site_settings', function () {
         $settings = Setting::all();
         $keys = array();
         foreach ($settings as $setting) {
             $keys[$setting->key] = $setting->value;
         }
         return $keys;
     });
     View::share('site_settings', app('site_settings'));
     $this->app->singleton('site_menus', function () {
         $categories = Category::all();
         return $categories;
     });
     View::share('site_menus', app('site_menus'));
     $this->app->singleton('site_statistic', function () {
         $article = Article::whereStatus('published')->count();
         $member = Contributor::whereStatus('activated')->count();
         return ['article' => $article, 'member' => $member];
     });
     View::share('site_statistic', app('site_statistic'));
     Validator::extend('check_password', function ($attribute, $value, $parameter) {
         if (count($parameter) > 0 && $parameter[0] == 'admin') {
             return Hash::check($value, Auth::guard('admin')->user()->getAuthPassword());
         }
         return Hash::check($value, Auth::user()->getAuthPassword());
     });
     Blade::directive('datetime', function ($expression) {
         return "<?php echo with{$expression}->format('d/m/Y H:i'); ?>";
     });
     Blade::directive('simpledate', function ($expression) {
         return "<?php echo with{$expression}->format('d M Y'); ?>";
     });
     Blade::directive('fulldate', function ($expression) {
         return "<?php echo with{$expression}->format('d F Y'); ?>";
     });
     Blade::directive('datetime', function ($expression) {
         return "<?php echo with{$expression}->format('d F Y h:m A'); ?>";
     });
 }
예제 #28
0
 protected function registerBladeDirectives()
 {
     // Charset
     Blade::directive('charset', function ($value) {
         return "<?php echo Arabic::getCharset({$value}); ?>";
     });
     // Compress
     Blade::directive('compress', function ($value) {
         return "<?php echo Arabic::compress({$value}); ?>";
     });
     // Glyphs
     Blade::directive('glyphs', function ($value) {
         return "<?php echo Arabic::utf8Glyphs({$value}); ?>";
     });
     // Identify
     Blade::directive('identify', function ($value) {
         return "<?php echo Arabic::identify({$value}); ?>";
     });
 }
예제 #29
0
 /**
  * Setup the views and template.
  * @param Template $template
  * @param Extender $extender
  * @param Request $request
  */
 public function boot_views(Template $template, Extender $extender, Request $request)
 {
     $this->loadViewsFrom(base_path('cms/assets/views'), 'cms');
     View::share('template', $template);
     View::share('modules', $extender);
     View::share('request', $request);
     // Check for development environment and inject services.
     $livereload = config('view.livereload');
     // Use livereload on local or development?
     if (env('APP_ENV') !== Application::ENV_PROD && $livereload) {
         $url = $livereload === true ? "localhost" : $livereload;
         $template->script('livereload', "http://{$url}:35729/livereload.js");
     }
     // Allow component tags.
     Blade::directive('component', function ($expression) {
         $args = explode(",", trim($expression, "()"));
         $componentClass = trim(array_shift($args));
         $arguments = "[" . implode(",", $args) . "]";
         return "<?php echo {$componentClass}::create({$arguments})->render(); ?>";
     });
 }
 /**
  * Register the blade directives
  *
  * @return void
  */
 private function bladeDirectives()
 {
     Blade::directive('role', function ($expression) {
         return "<?php if (\\Entrust::hasRole{$expression}) : ?>";
     });
     Blade::directive('endrole', function ($expression) {
         return "<?php endif; // Entrust::hasRole ?>";
     });
     Blade::directive('permission', function ($expression) {
         return "<?php if (\\Entrust::can{$expression}) : ?>";
     });
     Blade::directive('endpermission', function ($expression) {
         return "<?php endif; // Entrust::can ?>";
     });
     Blade::directive('ability', function ($expression) {
         return "<?php if (\\Entrust::ability{$expression}) : ?>";
     });
     Blade::directive('endability', function ($expression) {
         return "<?php endif; // Entrust::ability ?>";
     });
 }