classes/Routing/Wildcard.php
public function detectAction()
    {

        // If the path ends in one of the special actions, use that as the action
        // as long as the verb is a GET
        if (preg_match('#[a-z-]+$#i', $this->path, $matches)) {
            $action = $matches[0];

            // If posting to the create/edit route, treat as a 'post' route rather than
            // a 'create/edit' one.  This is a shorthand so the create forms can
            // post to themselves
            if ($action == 'create' && $this->verb == 'POST') {
                return 'store';
            } elseif ($action == 'edit' && $this->verb == 'POST') {
                return 'update';
            }

            // ... otherwise, use the route explicitly
            elseif (in_array($action, $this->actions)) {
                return $action;
            }
        }

        // If the path ends in a number, the verb defines what it is
        if (preg_match('#\d+$#', $this->path)) {
            switch ($this->verb) {
                case 'PUT':
                case 'POST':
                    return 'update';

                case 'DELETE':
                    return 'destroy';

                default:
                    return false;
            }
        }

        // Else, it must end with the controller name
        switch ($this->verb) {
            case 'POST':
                return 'store';

            case 'GET':
                return 'index';
        }

        // Must have been an erorr if we got here
        return false;
    }
public function detectAction()
    {

        // If the path ends in one of the special actions, use that as the action
        // as long as the verb is a GET
        if (preg_match('#[a-z-]+$#i', $this->path, $matches)) {
            $action = $matches[0];

            // If posting to the create/edit route, treat as a 'post' route rather than
            // a 'create/edit' one.  This is a shorthand so the create forms can
            // post to themselves
            if ($action == 'create' && $this->verb == 'POST') {
                return 'store';
            } elseif ($action == 'edit' && $this->verb == 'POST') {
                return 'update';
            }

            // ... otherwise, use the route explicitly
            elseif (in_array($action, $this->actions)) {
                return $action;
            }
        }

        // If the path ends in a number, the verb defines what it is
        if (preg_match('#\d+$#', $this->path)) {
            switch ($this->verb) {
                case 'PUT':
                case 'POST':
                    return 'update';

                case 'DELETE':
                    return 'destroy';

                default:
                    return false;
            }
        }

        // Else, it must end with the controller name
        switch ($this->verb) {
            case 'POST':
                return 'store';

            case 'GET':
                return 'index';
        }

        // Must have been an erorr if we got here
        return false;
    }
public function detectAction ( ) { // If the path ends in one of the special actions, use that as the action // as long as the verb is a GET if ( preg_match ( '#[a-z-]+$#i' , $ this -> path , $ matches ) ) { $ action = $ matches [ 0 ] ; // If posting to the create/edit route, treat as a 'post' route rather than // a 'create/edit' one.  This is a shorthand so the create forms can // post to themselves if ( $ action == 'create' && $ this -> verb == 'POST' ) { return 'store' ; } elseif ( $ action == 'edit' && $ this -> verb == 'POST' ) { return 'update' ; } // ... otherwise, use the route explicitly elseif ( in_array ( $ action , $ this -> actions ) ) { return $ action ; } } // If the path ends in a number, the verb defines what it is if ( preg_match ( '#\d+$#' , $ this -> path ) ) { switch ( $ this -> verb ) { case 'PUT' : case 'POST' : return 'update' ; case 'DELETE' : return 'destroy' ; default : return false ; } } // Else, it must end with the controller name switch ( $ this -> verb ) { case 'POST' : return 'store' ; case 'GET' : return 'index' ; } // Must have been an erorr if we got here return false ; }
Detect the action for a path
@return string 'create', 'update', 'edit', ....
Detect the action for a path