public function indexByProperty($propertyName)
    {
        $results = [];
        foreach ($this->toArray() as $item) {
            $key = mp\getValue($item, $propertyName);
            if ($key) {
                $results[$key] = $item;
            }
        }
        return $results;
    }
public function indexByProperty($propertyName)
    {
        $results = [];
        foreach ($this->toArray() as $item) {
            $key = mp\getValue($item, $propertyName);
            if ($key) {
                $results[$key] = $item;
            }
        }
        return $results;
    }
public function indexByProperty ( $ propertyName ) { $ results = [ ] ; foreach ( $ this -> toArray ( ) as $ item ) { $ key = mp \ getValue ( $ item , $ propertyName ) ; if ( $ key ) { $ results [ $ key ] = $ item ; } } return $ results ; }
Returns array indexed by specified property of collection elements.
If there is few elements with same property value, last will be used.

@param string $propertyName
@return array|object[]
Returns array indexed by specified property of collection elements . If there is few elements with same property value last will be used .