To create custom helper functions in Laravel, you can create a custom helper.php file on the app folder and load it using the composer
Follow the steps below to use your custom helper function in Laravel.
Create a helper.php file in your app folder
Load the helper from your composer.json file
"autoload": {
"classmap": [
...
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helpers.php" // INCLUDE THIS FILE
]
},
Finally, run composer dump autoload
composer dump-autoload