I have created file helpers.php
(app/helpers.php)
function test($var)
{
return $var;
}
I have changed app/start/global.php into
ClassLoader::addDirectories(array(
app_path().'/commands',
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/helpers.php',
));
Also composer.json into
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/helpers.php"
]
},
But when am I trying to call this function inside controller
$data = Test::all();
return test($data);
It throws me an error
Call to undefined function test()
What's wrong?