Where to place Blade::extend

前端 未结 3 1295
眼角桃花
眼角桃花 2020-12-05 18:29

I want to add the following code to my laravel project to support the break and continue statements in blade.

This is the code:

Blade::extend(functio         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-05 19:15

    Laravel 5 update:

    1) You may want to create Extensions\BladeExtensions.php folder\file on the same level as Models, Providers, Services folders

    2) BladeExtensions.php

    createMatcher('datetime');
    
                return preg_replace($pattern, '$1format(\'m/d/Y H:i\'); ?>', $view);
            });
        }
    
    }
    

    3) AppServiceProvider.php

    // ...
    use App\Extensions\BladeExtensions;
    
    class AppServiceProvider extends ServiceProvider
    {
        // ...
        public function register()
        {
            // ...
    
            BladeExtensions::register();
        }
    
    }
    

提交回复
热议问题