Laravel Macros Postmortem
20
Jan
Laravel gives you ability to add methods to a class at runtime by using Macroable (IlluminateSupportTraitsMacroable) Trait . You need to use Macroable trait inside the class in which you want to add methods at run time. Here is an example from the Laravel Documentation. following code adds a toUpper method to the Collection class: How to register your Macros? …