Answer the question
In order to leave comments, you need to log in
How and where to create your own function and how to access it?
Hello!
Can you please tell me if it is possible to create your own separate functions (without using a controller. For example, laravel-function dd() ) in Laravel? If so, how and where should they be created and how should they be accessed after that? An example of what I want to do: I want to create a function that will show whether the user is online or not. And call it where the output of users or a specific user occurs. If there is a better solution to this problem, please advise.
Answer the question
In order to leave comments, you need to log in
The solution to my question was this way:
jonybang.ru/laravel-5-2-custom-helpers
Create helpers.php file in app folder
In composer.json file add lines to autoload
"files": [
"app/helpers.php"
]
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helpers.php"
]
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question