Illuminate\Routing\Router::currentRouteAction PHP Method

currentRouteAction() public method

Get the current route action.
public currentRouteAction ( ) : string | null
return string | null
    public function currentRouteAction()
    {
        if (!$this->current()) {
            return;
        }
        $action = $this->current()->getAction();
        return isset($action['controller']) ? $action['controller'] : null;
    }

Usage Example

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;
 }
All Usage Examples Of Illuminate\Routing\Router::currentRouteAction