public function getData($namespace = null)
    {
        if(!self::$pluginData) {
            // try to find the model via namespace
            if (!$namespace) {
                // if we are in a model
                if (property_exists($this, 'namespace')) {
                    self::$pluginData = $this;
                } /// When calling the method from a parent class that uses this class as a parent
                else {
                    // try to find plugin's model via reflection class
                    try{
                        $reflector = new \ReflectionClass(self::class);
                        $fn = $reflector->getFileName();
                        $explode = explode('plugins/', str_replace('\\', '/', dirname($fn)));
                        if (isset($explode[1])) {
                            $pluginNamespace = str_replace('/Controllers', '', $explode[1]);
                            self::$pluginData = Plugin::where('namespace', $pluginNamespace)->first();
                        }

                    }catch(\Exception $e){
                        return null;
                    }
                }
            }else {
                // Return a requested plugin
                self::$pluginData = $this->getByNamespace($namespace);
            }
        }

        if (!self::$pluginData) {
            return null;
        }

        return self::$pluginData;
    }
public function getData($namespace = null)
    {
        if(!self::$pluginData) {
            // try to find the model via namespace
            if (!$namespace) {
                // if we are in a model
                if (property_exists($this, 'namespace')) {
                    self::$pluginData = $this;
                } /// When calling the method from a parent class that uses this class as a parent
                else {
                    // try to find plugin's model via reflection class
                    try{
                        $reflector = new \ReflectionClass(self::class);
                        $fn = $reflector->getFileName();
                        $explode = explode('plugins/', str_replace('\\', '/', dirname($fn)));
                        if (isset($explode[1])) {
                            $pluginNamespace = str_replace('/Controllers', '', $explode[1]);
                            self::$pluginData = Plugin::where('namespace', $pluginNamespace)->first();
                        }

                    }catch(\Exception $e){
                        return null;
                    }
                }
            }else {
                // Return a requested plugin
                self::$pluginData = $this->getByNamespace($namespace);
            }
        }

        if (!self::$pluginData) {
            return null;
        }

        return self::$pluginData;
    }
public function getData ( $ namespace = null ) { if ( ! self :: $ pluginData ) { // try to find the model via namespace if ( ! $ namespace ) { // if we are in a model if ( property_exists ( $ this , 'namespace' ) ) { self :: $ pluginData = $ this ; } /// When calling the method from a parent class that uses this class as a parent else { // try to find plugin's model via reflection class try { $ reflector = new \ ReflectionClass ( self :: class ) ; $ fn = $ reflector -> getFileName ( ) ; $ explode = explode ( 'plugins/' , str_replace ( '\\' , '/' , dirname ( $ fn ) ) ) ; if ( isset ( $ explode [ 1 ] ) ) { $ pluginNamespace = str_replace ( '/Controllers' , '' , $ explode [ 1 ] ) ; self :: $ pluginData = Plugin :: where ( 'namespace' , $ pluginNamespace ) -> first ( ) ; } } catch ( \ Exception $ e ) { return null ; } } } else { // Return a requested plugin self :: $ pluginData = $ this -> getByNamespace ( $ namespace ) ; } } if ( ! self :: $ pluginData ) { return null ; } return self :: $ pluginData ; }
Get plugin data.

@param  null $namespace
@return PluginTrait|null|object
@throws Exception
Get plugin data .