-
-
Save vienhoang/11121579 to your computer and use it in GitHub Desktop.
Laravel: Make the Controller title a little bit prettier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function routeClass($separator = ' - ') | |
{ | |
$routeArray = Str::parseCallback(Route::currentRouteAction(), null); | |
if (last($routeArray) != null) { | |
// Remove 'controller' from the controller name. | |
$controller = str_replace('Controller', '', class_basename(head($routeArray))); | |
// Take out the method from the action. | |
$action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', last($routeArray)); | |
return Str::title($controller . $separator . $action); | |
} | |
return 'closure'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment