I have the same problem, i'm trying to extend Illuminate\Html\HtmlBuilder through workbench but i can't get it to work, i always get 'class not found' or 'method not found'.
Ofcoursse you can extend it. Just then make sure it is loaded via the composer Autoloader and replace the HTML facade in config/app.php as well.
However, it is easier to just use HTML::macro for smaller custom functions. Maybe you want to open external links in another tab and thus add target="_blank" to your links. That would work like this:
HTML::macro('externalLink', function($url, $title = null, $attributes = array(), $secure = null)
{
return HTML::link($url, $title, $attributes + ['target' => '_blank'], $secure);
});
HeadUp: I coded this in browser, so there might be some typos or sth.
Thanks @Alxy, what I'm trying to do is to have a more maintainable approach so that I'd just add my package to composer and configure it instead of copying/pasting around my macros
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community