F
F
freeeeez2016-05-30 14:27:03
Laravel
freeeeez, 2016-05-30 14:27:03

How to connect your function in Laravel template?

catalog.blade.php uses date formatting with its own newDate() function. If the function is written in the template code, then everything works as it should, but if it is moved to a separate file (functions folder / time.blade.php file) and connected via @include('functions.time'), Laravel does not see it. Maybe I'm not doing something? How to put all the functions that I will need in the templates into a separate file and not litter the templates?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tesla, 2016-05-30
@freeeeez

Templates are not for functions. All helper functions need to be moved to a separate file and included in composer.json:

{
    "autoload": {
        "files": [
            "helpers/functions.php",
        ]
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question