Support the ongoing development of Laravel.io →
Configuration Views
Last updated 2 years ago.
0

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'.

Last updated 2 years ago.
0
Solution

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.

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jerodev jerodev Joined 20 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.