I have my Helper file located at app/Helpers/Helper.php
class Helper {
// Add body class
public static function bodyClass() {
$body_classes = array();
$class = "";
foreach ( \Request::segments() as $segment ) {
if ( is_numeric( $segment ) || empty( $segment ) ) {
continue;
}
$class .= ! empty( $class ) ? "-" . $segment : $segment;
array_push( $body_classes, $class );
}
return ! empty( $body_classes ) ? implode( ' ', $body_classes ) : NULL;
}
}
Then in my composer.json
, I autoloaded this Helper file like this:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helpers/Helper.php"
]
},
Then in one of my master views, I have this:
<body class="{{ Helper::bodyClass() }}">
But I get an error saying:
Class 'Helper' not found
I also did dump autoload so that shouldn't be the issue. Anyone have any clues?
Thanks!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1OrNBdU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire