src/Schema.php
public function getReverseRelations($many = -1)
    {
        $results = [];
        $name = $this->getName();

        $payload = cradle()->makePayload();

        cradle()->trigger(
            'system-schema-search',
            $payload['request'],
            $payload['response']
        );

        $rows = $payload['response']->getResults('rows');

        if (empty($rows)) {
            return $results;
        }

        foreach ($rows as $row) {
            $schema = Schema::i($row['name']);
            $table = $row['name'] . '_' . $name;

            $relations = $schema->getRelations();
            if (!isset($relations[$table]['many'])
                || (
                    $many != -1
                    && $many != $relations[$table]['many']
                )
            ) {
                continue;
            }

            $results[$table] = $relations[$table];
            $results[$table]['source'] = $schema->getAll(false);
        }

        return $results;
    }
public function getReverseRelations($many = -1)
    {
        $results = [];
        $name = $this->getName();

        $payload = cradle()->makePayload();

        cradle()->trigger(
            'system-schema-search',
            $payload['request'],
            $payload['response']
        );

        $rows = $payload['response']->getResults('rows');

        if (empty($rows)) {
            return $results;
        }

        foreach ($rows as $row) {
            $schema = Schema::i($row['name']);
            $table = $row['name'] . '_' . $name;

            $relations = $schema->getRelations();
            if (!isset($relations[$table]['many'])
                || (
                    $many != -1
                    && $many != $relations[$table]['many']
                )
            ) {
                continue;
            }

            $results[$table] = $relations[$table];
            $results[$table]['source'] = $schema->getAll(false);
        }

        return $results;
    }
public function getReverseRelations ( $ many = - 1 ) { $ results = [ ] ; $ name = $ this -> getName ( ) ; $ payload = cradle ( ) -> makePayload ( ) ; cradle ( ) -> trigger ( 'system-schema-search' , $ payload [ 'request' ] , $ payload [ 'response' ] ) ; $ rows = $ payload [ 'response' ] -> getResults ( 'rows' ) ; if ( empty ( $ rows ) ) { return $ results ; } foreach ( $ rows as $ row ) { $ schema = Schema :: i ( $ row [ 'name' ] ) ; $ table = $ row [ 'name' ] . '_' . $ name ; $ relations = $ schema -> getRelations ( ) ; if ( ! isset ( $ relations [ $ table ] [ 'many' ] ) || ( $ many != - 1 && $ many != $ relations [ $ table ] [ 'many' ] ) ) { continue ; } $ results [ $ table ] = $ relations [ $ table ] ; $ results [ $ table ] [ 'source' ] = $ schema -> getAll ( false ) ; } return $ results ; }
Returns reverse relational data

@param int $many

@return array
Returns reverse relational data