diff --git a/README.md b/README.md index d7f2ec4..0a69107 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ $states->setLocale('ru')->sortBy('name'); // States will be sorted by Russian tr $states->find(['code' => 472039]); // Find 1+ divisions that match specified parameters $states->findOne(['code' => 472039]); // Return the first match only $states->findOneByCode(472039); // Convenience magic method +$states->toArray(); // Return a flat array of states +$states->pluck('name'); // Return a flat array of state names ``` ## Common methods on division objects diff --git a/src/Collections/MemberCollection.php b/src/Collections/MemberCollection.php index 1b06e43..f96f988 100644 --- a/src/Collections/MemberCollection.php +++ b/src/Collections/MemberCollection.php @@ -53,6 +53,17 @@ public function toArray() return $array; } + /** + * @param string $key + * @return array + */ + public function pluck($key) + { + return array_map(function($division) use ($key) { + return isset($division[$key]) ? $division[$key] : null; + }, $this->toArray()); + } + /** * @return mixed */