public static function query()
    {
        if (static::$builder instanceof Builder) {
            if (static::$builder->getModel() == static::class) {
                return static::$builder;
            }
        }

        // Reflection action
        $reflection = new \ReflectionClass(static::class);

        $properties = $reflection->getDefaultProperties();

        if ($properties['table'] == null) {
            $parts = explode('\\', static::class);

            $table = end($parts);

            $table = Str::camel(strtolower($table)).'s';
        } else {
            $table = $properties['table'];
        }

        if (!is_null($properties['connexion'])) {
            DB::connection($properties['connexion']);
        }

        if (!is_null($properties['prefix'])) {
            $prefix = $properties['prefix'];
        } else {
            $prefix = DB::getConnectionAdapter()->getTablePrefix();
        }

        $table = $prefix.$table;

        static::$builder = new Builder($table, DB::getPdo());

        static::$builder->setPrefix($prefix);

        static::$builder->setModel(static::class);

        return static::$builder;
    }
public static function query()
    {
        if (static::$builder instanceof Builder) {
            if (static::$builder->getModel() == static::class) {
                return static::$builder;
            }
        }

        // Reflection action
        $reflection = new \ReflectionClass(static::class);

        $properties = $reflection->getDefaultProperties();

        if ($properties['table'] == null) {
            $parts = explode('\\', static::class);

            $table = end($parts);

            $table = Str::camel(strtolower($table)).'s';
        } else {
            $table = $properties['table'];
        }

        if (!is_null($properties['connexion'])) {
            DB::connection($properties['connexion']);
        }

        if (!is_null($properties['prefix'])) {
            $prefix = $properties['prefix'];
        } else {
            $prefix = DB::getConnectionAdapter()->getTablePrefix();
        }

        $table = $prefix.$table;

        static::$builder = new Builder($table, DB::getPdo());

        static::$builder->setPrefix($prefix);

        static::$builder->setModel(static::class);

        return static::$builder;
    }
public static function query ( ) { if ( static :: $ builder instanceof Builder ) { if ( static :: $ builder -> getModel ( ) == static :: class ) { return static :: $ builder ; } } // Reflection action $ reflection = new \ ReflectionClass ( static :: class ) ; $ properties = $ reflection -> getDefaultProperties ( ) ; if ( $ properties [ 'table' ] == null ) { $ parts = explode ( '\\' , static :: class ) ; $ table = end ( $ parts ) ; $ table = Str :: camel ( strtolower ( $ table ) ) . 's' ; } else { $ table = $ properties [ 'table' ] ; } if ( ! is_null ( $ properties [ 'connexion' ] ) ) { DB :: connection ( $ properties [ 'connexion' ] ) ; } if ( ! is_null ( $ properties [ 'prefix' ] ) ) { $ prefix = $ properties [ 'prefix' ] ; } else { $ prefix = DB :: getConnectionAdapter ( ) -> getTablePrefix ( ) ; } $ table = $ prefix . $ table ; static :: $ builder = new Builder ( $ table , DB :: getPdo ( ) ) ; static :: $ builder -> setPrefix ( $ prefix ) ; static :: $ builder -> setModel ( static :: class ) ; return static :: $ builder ; }
Initialize the connection

@return Builder
@throws
Initialize the connection