How to pass a custom function to a Laravel Blade template?

You don’t have to pass anything to blade. If you define your function, you can use it from blade.


  1. Create a new app/helpers.php file.
  2. Add your trim_characters function to it.
  3. Add that file to your composer.json file.
  4. Run composer dump-autoload.

Now just use the function directly in blade:

{{ trim_characters($string) }}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)