You can add a macro by following these steps:
- Create a new provider called MacroServiceProvider.
-
Add your macro to the registration method.
public function register()
{
FormBuilder ::macro('time', function ($name, $default, $otherparams, ...)
{
....
}
}
-
Register MacroServiceProvider in your app.config file.
'providers' => [
\App\Providers\MacroServiceProvider::class,
'AltThree\Bus\BusServiceProvider',
'Illuminate\Notifications\NotificationServiceProvider',
-
Run the linker dump-autoload -o on a command line open in your project folder.
-
You can now use your macro in your view files.
source
to share