currentRouteAction() public method

Get the current route action.
public currentRouteAction ( ) : string | null
return string | null
Example #1
0
 /**
  * Get the current controller action name.
  *
  * @param  bool  $removeHttpMethod
  * @return string|null
  */
 public function action($removeHttpMethod = true)
 {
     if ($action = $this->router->currentRouteAction()) {
         $action = last(Str::parseCallback($action, null));
         if ($removeHttpMethod) {
             $action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', $action);
         }
         return Str::snake($action, '-');
     }
     return null;
 }
 /**
  * Get the current method name with the prefix 'get', 'post', 'put', 'delete', 'show' trimmed
  *
  * @return string|null
  */
 public function getMethod()
 {
     $action = $this->_router->currentRouteAction();
     if ($action) {
         $extractedController = last(Str::parseCallback($action, null));
         // Trim the "show", "post", "put", "delete", "get" if this is the
         // prefix of the method name
         return $extractedController ? preg_replace('/^(show|get|put|delete|post)(.+)$/', '${2}', $extractedController) : null;
     }
     return null;
 }
Example #3
0
 /**
  * Get the current route action.
  *
  * @return string|null 
  * @static 
  */
 public static function currentRouteAction()
 {
     return \Illuminate\Routing\Router::currentRouteAction();
 }