Laravel 5 Helpers

As I developed an application with Laravel 5 I encountered situations where I wanted to allow people to reference things, kind of like how @paddoswam becomes a link and a notification.

So my first attempt became something like this with the text being “today I used preg_replace @paddoswam with some help from @someone”.

It works but it’s not very pretty and only 1 functions.

Next up I tried to create a comment field where you could add bold and italic text the result, I shall not share, wasn’t pretty..

So I moved it to a class in App/Helpers/Text.php:

And registered a class alias:

config/app.php

Now we have readable and relatively pretty Blade template code like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.