public static function getStructure($withoutGuarded = false, $asKey = false)
    {
        $t = new self;

	    # if structure is defined => return structure

	    if(isset(static::$_structure)){
		    return static::$_structure;
	    }

        $table = $t->getTable();

        $columns = array();

        switch (DB::connection()->getConfig('driver')) {
            case 'pgsql':
                $query = "SELECT column_name FROM information_schema.columns WHERE table_name = '".$table."'";
                $column_name = 'column_name';
                $reverse = true;
                break;

            case 'mysql':
                $query = 'SHOW COLUMNS FROM '.$table;
                $column_name = 'Field';
                $reverse = false;
                break;

            case 'sqlsrv':
                $parts = explode('.', $table);
                $num = (count($parts) - 1);
                $table = $parts[$num];
                $query = "SELECT column_name FROM ".DB::connection()->getConfig('database').".INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'".$table."'";
                $column_name = 'column_name';
                $reverse = false;
                break;

            default:
                # Try to guess structure with first Element
                $table = self::where('id', '!=', 'x')->first();

                if($table){
                    $columns = array_keys($table->getAttributes());
                } else {
                    $error = 'Database driver not supported: you must define a static _structure variable '.DB::connection()->getConfig('driver');
                    throw new \Exception($error);
                }
                break;
        }

        if (!$columns) {
            $columns = array();

            foreach(DB::select($query) as $column)
            {
                $columns[] = $column->$column_name;
            }

            if($reverse)
            {
                $columns = array_reverse($columns);
            }
        }

        if($withoutGuarded){

            $kColumns = array_flip($columns);

            foreach($t->guarded as $key){

                if(isset($kColumns[$key])){

                    unset($columns[$kColumns[$key]]);
                }
            }

            # remove timestamp

            $updated_at = array_search('updated_at', $columns);

            if($updated_at !== false){
                unset($columns['updated_at']);
            }

            $created_at = array_search('created_at', $columns);

            if($created_at !== false){
                unset($columns['created_at']);
            }

        }

        # Switch keys if we want column name as key
        if($asKey)
        {
            $columns = array_flip($columns);
        }

        return $columns;
    }