M
M
Maxim Spiridonov2015-04-20 16:18:36
Laravel
Maxim Spiridonov, 2015-04-20 16:18:36

Why don't macros work in laravel 5?

Created a macro in AppServiceProvider

<?php namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider {
    /**
      * Bootstrap any application services.
      *
      * @return void
      */
public function boot()
{
    \Html::macro('test', function() {
        return 'default';
    });
}

then I try to call it in the template shop.blade.php
{{ Html::test() }}
But for some reason I get an error
Method test does not exist. (View: C:\xampp\htdocs\lar.ru\resources\views\sub\test\shop.blade.php)

The macro package installed, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2015-04-20
@AmdY

Check if you registered your provider exactly in config/app.php, check the sequence of registering providers, if you have \Html, it was cut out in laravel 5 .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question