public function group($name, $data = [])
    {
        $app = 'App\Groups\\'.ucwords($name);
        $core = 'Scara\Http\Groups\\'.ucwords($name);

        if (class_exists($app)) {
            $class = new $app();
        } else {
            if (class_exists($core)) {
                $class = new $core();
            } else {
                throw new \Exception("$name group could not be found in the application or in Scara's core");
            }
        }

        if (method_exists($class, 'init')) {
            if (!empty($data)) {
                $class->init($data);
            } else {
                $class->init();
            }

            if (in_array('Scara\Http\Groups\Groupable', class_uses($class))) {
                // class uses Groupable trait. call finalize
                $class->finalize();
            } elseif (method_exists($class, 'finalize')) {
                $class->finalize(); // not using Groupable trait, but still has a finalize method defined
            }
        } else {
            throw new \Exception("$name group does not define the required init method!");
        }

        return $this;
    }
public function group($name, $data = [])
    {
        $app = 'App\Groups\\'.ucwords($name);
        $core = 'Scara\Http\Groups\\'.ucwords($name);

        if (class_exists($app)) {
            $class = new $app();
        } else {
            if (class_exists($core)) {
                $class = new $core();
            } else {
                throw new \Exception("$name group could not be found in the application or in Scara's core");
            }
        }

        if (method_exists($class, 'init')) {
            if (!empty($data)) {
                $class->init($data);
            } else {
                $class->init();
            }

            if (in_array('Scara\Http\Groups\Groupable', class_uses($class))) {
                // class uses Groupable trait. call finalize
                $class->finalize();
            } elseif (method_exists($class, 'finalize')) {
                $class->finalize(); // not using Groupable trait, but still has a finalize method defined
            }
        } else {
            throw new \Exception("$name group does not define the required init method!");
        }

        return $this;
    }
public function group ( $ name , $ data = [ ] ) { $ app = 'App\Groups\\' . ucwords ( $ name ) ; $ core = 'Scara\Http\Groups\\' . ucwords ( $ name ) ; if ( class_exists ( $ app ) ) { $ class = new $ app ( ) ; } else { if ( class_exists ( $ core ) ) { $ class = new $ core ( ) ; } else { throw new \ Exception ( "$name group could not be found in the application or in Scara's core" ) ; } } if ( method_exists ( $ class , 'init' ) ) { if ( ! empty ( $ data ) ) { $ class -> init ( $ data ) ; } else { $ class -> init ( ) ; } if ( in_array ( 'Scara\Http\Groups\Groupable' , class_uses ( $ class ) ) ) { // class uses Groupable trait. call finalize $ class -> finalize ( ) ; } elseif ( method_exists ( $ class , 'finalize' ) ) { $ class -> finalize ( ) ; // not using Groupable trait, but still has a finalize method defined } } else { throw new \ Exception ( "$name group does not define the required init method!" ) ; } return $ this ; }
Loads in a group for given controller method.

@param string $name - The group name
@param array  $data - Data to pass to group

@throws \Exception

@return \Scara\Http\Controller
Loads in a group for given controller method .