Tools\Model\Table\Table::getRelatedInUse PHP Method

getRelatedInUse() public method

Get all related entries that have been used so far
public getRelatedInUse ( string $tableName, string | null $groupField = null, string $type = 'all', array $options = [] ) : Query
$tableName string The related model
$groupField string | null Field to group by
$type string Find type
$options array
return Cake\ORM\Query
    public function getRelatedInUse($tableName, $groupField = null, $type = 'all', $options = [])
    {
        if ($groupField === null) {
            $groupField = $this->belongsTo[$tableName]['foreignKey'];
        }
        $defaults = ['contain' => [$tableName], 'group' => $groupField, 'order' => isset($this->{$tableName}->order) ? $this->{$tableName}->order : [$tableName . '.' . $this->{$tableName}->displayField() => 'ASC']];
        if ($type === 'list') {
            $defaults['fields'] = [$tableName . '.' . $this->{$tableName}->primaryKey(), $tableName . '.' . $this->{$tableName}->displayField()];
        }
        $options += $defaults;
        return $this->find($type, $options);
    }