Pantheon\Terminus\Collections\TerminusCollection::listing PHP Method

listing() public method

Returns an array of data where the keys are the attribute $key and the values are the attribute $value
public listing ( string $key = 'id', mixed $value = 'name' ) : array
$key string Name of attribute to make array keys
$value mixed Name(s) of attribute(s) to comprise array values
return array Array rendered as requested $this->attribute->$key = $this->attribute->$value
    public function listing($key = 'id', $value = 'name')
    {
        $members = array_combine(array_map(function ($member) use($key) {
            return $member->get($key);
        }, $this->models), array_map(function ($member) use($value) {
            if (is_scalar($value)) {
                return $member->get($value);
            }
            $list = [];
            foreach ($value as $item) {
                $list[$item] = $member->get($item);
            }
            return $list;
        }, $this->models));
        return $members;
    }