Skip to content

Instantly share code, notes, and snippets.

@tucq88
Forked from dwightwatson/RouteClass.php
Last active August 29, 2015 14:13
Show Gist options
  • Save tucq88/f51d484b60130b1bf5a3 to your computer and use it in GitHub Desktop.
Save tucq88/f51d484b60130b1bf5a3 to your computer and use it in GitHub Desktop.
<?php
public function routeClass()
{
$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::slug($controller . '-' . $action);
}
return 'closure';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment