{"id":727,"date":"2018-07-12T04:04:27","date_gmt":"2018-07-11T19:04:27","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=727"},"modified":"2020-07-03T18:15:49","modified_gmt":"2020-07-03T09:15:49","slug":"%e5%85%a8100%e7%a8%ae%e9%a1%9e%ef%bc%81laravel-5-6%e3%81%ae%e3%82%b3%e3%83%ac%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e5%ae%9f%e4%be%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=727","title":{"rendered":"\u5168117\u7a2e\u985e\uff01Laravel 5.6\u301c7.x\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5b9f\u4f8b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u4ee5\u524d\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=493\">Laravel\u306e\u4fbf\u5229\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30fb\u30e1\u30bd\u30c3\u30c9\uff17\u9078\uff01<\/a>\u300d\u3092\u516c\u958b\u3057\u305f\u6642\u304b\u3089\u3044\u3064\u304b\u3084\u308a\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u304c\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">\u5168Laravel Collection\u30e1\u30bd\u30c3\u30c9<\/strong><\/p>\n<p>\u306e\u4f7f\u3044\u65b9\u3092\u518d\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u306a\u305c\u306a\u3089\u3001<code>Laravel<\/code>\u306f\u30de\u30a4\u30ca\u30fc\u30fb\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u3067\u3082\u65b0\u3057\u3044\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u306e\u3067\u3001\u5b9a\u671f\u7684\u306b\u30c1\u30a7\u30c3\u30af\u3092\u3057\u3066\u304a\u304b\u306a\u3044\u3068\u305b\u3063\u304b\u304f\u306e\u4fbf\u5229\u306a\u6a5f\u80fd\u3092\u898b\u9003\u3057\u3066\u3057\u307e\u3046\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u904e\u53bb\u306b\u3042\u307e\u308a\u306b\u3082\u81a8\u5927\u306a\u91cf\u306b\u306a\u308a\u305d\u3046\u3067\u656c\u9060\u3057\u3066\u305f\u300c<strong>Laravel Collection<\/strong>\u300d\u306e\u5168\u5b9f\u4f8b\u3092\u30b1\u30fc\u30b9\u5225\u3067\u307e\u3068\u3081\u3066\u304a\u5c4a\u3051\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-417 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/9.png\" alt=\"\" width=\"370\" height=\"220\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/9.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/9-300x178.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 5.6 \u301c Laravel 7.x<\/p>\n<p><strong>\u3010\u8ffd\u8a18\uff1a2020.3.7\u3011<\/strong>\u3053\u306e\u8a18\u4e8b\u306f\u516c\u958b\u5f53\u6642<code>Laravel 5.6<\/code>\u5411\u3051\u306b\u4f5c\u6210\u3055\u308c\u305f\u3082\u306e\u306b\u52a0\u7b46\u4fee\u6b63\u3055\u308c\u305f\u3082\u306e\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u8a18\u4e8b\u306e\u516c\u958b\u3088\u308a\u5f8c\u306b\u8ffd\u52a0\u3055\u308c\u305f\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3044\u3066\u306f\u3001\u6709\u52b9\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u60c5\u5831\u3092\u8f09\u305b\u3066\u3044\u307e\u3059\u304c\u3001\u3082\u3057\u4f55\u3082\u8a18\u8f09\u304c\u7121\u3044\u5834\u5408\u306f<code>Laravel 5.6<\/code>\u4ee5\u964d\u3067\u4f7f\u3048\u308b\u3082\u306e\u3068\u304a\u8003\u3048\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\u3010\u8ffd\u8a18\uff1a2020.7.3\u3011<\/strong><code>takeUntil()<\/code>\u3001<code>takeWhile()<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<h1>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h1>\n<h2>get()\u3067\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p><code>get()<\/code>\u306f<code>Collection<\/code>\u306e\u4e00\u756a\u57fa\u672c\u7684\u306a\u30e1\u30bd\u30c3\u30c9\u3067\u3001PHP\u306e\u914d\u5217\u306e\u3088\u3046\u306b\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    'id' =&gt; 1,<\/strong>\r\n<strong>    'name' =&gt; '\u9234\u6728',<\/strong>\r\n<strong>    'age' =&gt; 20<\/strong>\r\n<strong>]<\/strong>);\r\necho $collection-&gt;<strong>get('name')<\/strong>; \/\/ \u9234\u6728<\/pre>\n<p>\u307e\u305f\u3001\u30ad\u30fc\u304c\u7121\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u30c7\u30fc\u30bf\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\necho $collection-&gt;<strong>get(0)<\/strong>; \/\/ \u9234\u6728<\/pre>\n<p>\u306a\u304a\u3001\u3082\u3057\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u306f<code>null<\/code>\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u7b2c\uff12\u5f15\u6570\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u6307\u5b9a\u3057\u3066\u304a\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'id' =&gt; 1,\r\n    'name' =&gt; '\u9234\u6728',\r\n    'age' =&gt; 20\r\n]);\r\necho $collection-&gt;<strong>get('todofuken', '\u6771\u4eac\u90fd')<\/strong>; \/\/ <strong>\u6771\u4eac\u90fd<\/strong><\/pre>\n<p>\u203b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f<code>function()<\/code>\u3067\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u305d\u306e\u5834\u5408\u306f<code>return<\/code>\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>pluck()\u3067\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u306e\u914d\u5217\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001<code>name<\/code>\u306e\u5024\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, <strong>'name' =&gt; '\u9234\u6728'<\/strong>, 'age' =&gt; 20],\r\n    ['id' =&gt; 2, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 23],\r\n    ['id' =&gt; 3, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 20],\r\n    ['id' =&gt; 4, <strong>'name' =&gt; '\u5c71\u672c'<\/strong>, 'age' =&gt; 25],\r\n    ['id' =&gt; 5, <strong>'name' =&gt; '\u85e4\u539f'<\/strong>, 'age' =&gt; 25],\r\n]);\r\n$names = $collection-&gt;<strong>pluck('name')<\/strong>;\r\nprint_r($names-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u5c71\u672c\r\n    [4] =&gt; \u85e4\u539f\r\n)<\/pre>\n<p>\u307e\u305f\u3001\u9023\u60f3\u914d\u5217\u3068\u3057\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001<code>id<\/code>\u3092\u30ad\u30fc\u3068\u3059\u308b\u9023\u60f3\u914d\u5217\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    [<strong>'id' =&gt; 3<\/strong>, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20],\r\n    [<strong>'id' =&gt; 5<\/strong>, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 23],\r\n    [<strong>'id' =&gt; 6<\/strong>, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    [<strong>'id' =&gt; 9<\/strong>, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 25],\r\n    [<strong>'id' =&gt; 11<\/strong>, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 25],\r\n]);\r\n$names = $collection-&gt;<strong>pluck('name', 'id')<\/strong>;\r\nprint_r($names-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u3067\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[3]<\/strong> =&gt; \u9234\u6728\r\n    <strong>[5]<\/strong> =&gt; \u4f50\u85e4\r\n    <strong>[6]<\/strong> =&gt; \u7530\u4e2d\r\n    <strong>[9]<\/strong> =&gt; \u5c71\u672c\r\n    <strong>[11]<\/strong> =&gt; \u85e4\u539f\r\n)\r\n<\/pre>\n<h2>toArray()\u3067\u4e2d\u8eab\u3092\u914d\u5217\u3067\u53d6\u5f97\u3059\u308b<\/h2>\n<p><code>Collection<\/code>\u306e\u4e2d\u8eab\u3092\u914d\u5217\u306b\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d'])-&gt;all();\r\n$array = $collection-&gt;<strong>toArray()<\/strong>; \/\/ \u914d\u5217<\/pre>\n<h2>all()\u3067\u4e2d\u8eab\u3092\u914d\u5217\u3067\u53d6\u5f97\u3059\u308b<\/h2>\n<p><code>all()<\/code>\u306f\u307b\u307c<code>toArray()<\/code>\u3068\u540c\u3058\u3067\u3001<code>Collection<\/code>\u306e\u4e2d\u8eab\u3092\u914d\u5217\u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d'])-&gt;all();\r\n$array = $collection-&gt;<strong>all()<\/strong>; \/\/ \u914d\u5217<\/pre>\n<p><code>toArray()<\/code>\u3068\u306e\u9055\u3044\u306f\u3001<code>Collection<\/code>\u306e\u4e2d\u306b\u3055\u3089\u306b<code>Collection<\/code>\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    collect([1, 2, 3]),\r\n    collect([4, 5, 6]),\r\n    collect([7, 8, 9])\r\n]);\r\ndd($collection-&gt;<strong>toArray()<\/strong>);<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001<strong>toArray()\u306e\u5834\u5408\u306f\u5168\u3066\u306e\u8981\u7d20\u3092PHP\u306e\u914d\u5217\u306b\u5909\u63db\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-732\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_to_array.png\" alt=\"\" width=\"150\" height=\"330\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_to_array.png 150w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_to_array-136x300.png 136w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/p>\n<p>\u3053\u308c\u3068\u306f\u9006\u306b\u3001<strong>all()\u3092\u4f7f\u3063\u305f\u5834\u5408\u3001Collection\u306fCollection\u306e\u307e\u307e\u3067\u6b8b\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><\/p>\n<pre>$collection = collect([\r\n    collect([1, 2, 3]),\r\n    collect([4, 5, 6]),\r\n    collect([7, 8, 9])\r\n]);\r\ndd($collection-&gt;<strong>all()<\/strong>);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-733\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_to_all.png\" alt=\"\" width=\"203\" height=\"442\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_to_all.png 203w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_to_all-138x300.png 138w\" sizes=\"auto, (max-width: 203px) 100vw, 203px\" \/><\/p>\n<p>\u305d\u306e\u305f\u3081\u3001<code>foreach<\/code>\u30eb\u30fc\u30d7\u306a\u3069\u306e\u4e2d\u3067\u3055\u3089\u306b<code>Collection<\/code>\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f<code>all()<\/code>\u3092\u4f7f\u3046\u307b\u3046\u304c\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>take()\u3067\u6307\u5b9a\u3057\u305f\u4ef6\u6570\u3060\u3051\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b<\/h2>\n<p><code>Collection<\/code>\u306e\u4e2d\u304b\u3089\u7279\u5b9a\u306e\u4ef6\u6570\u3060\u3051\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$chunk = $collection-&gt;<strong>take(3)<\/strong>;\r\nprint_r($chunk-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n)<\/pre>\n<p>\u306a\u304a\u3001\u30de\u30a4\u30ca\u30b9\u306e\u6570\u5b57\u3092\u4f7f\u3046\u3068\u300c\u5f8c\u308d\u304b\u3089\u25cf\u4ef6\u306e\u30c7\u30fc\u30bf\u300d\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$chunk = $collection-&gt;<strong>take(-2)<\/strong>;\r\nprint_r($chunk-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[3]<\/strong> =&gt; \u5c71\u672c\r\n    <strong>[4]<\/strong> =&gt; \u85e4\u539f\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>takeUntil()\u3067\u7279\u5b9a\u306e\u6761\u4ef6\u304c\u6765\u308b\u307e\u3067\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u30c7\u30fc\u30bf\u3092\uff11\u4ef6\u305a\u3064\u30c1\u30a7\u30c3\u30af\u3057\u300c\u4e09\u90ce\u300d\u3055\u3093\u304c\u6765\u308b\u307e\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u592a\u90ce', '\u6b21\u90ce', '\u4e09\u90ce', '\u56db\u90ce', '\u4e94\u90ce']);\r\n\r\n$users = <strong>$collection-&gt;takeUntil(function ($item) {<\/strong>\r\n\r\n<strong>    return ($item === '\u4e09\u90ce'); \/\/ \ud83d\udc48 \u4e09\u90ce\u3055\u3093\u304c\u6765\u308b\u307e\u3067\u7d9a\u304f\uff08\u305f\u3060\u3057\u3001\u4e09\u90ce\u3055\u3093\u306f\u542b\u307e\u306a\u3044\uff09<\/strong>\r\n\r\n<strong>})<\/strong>;\r\n\r\ndd($users-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>array:2 <strong>[\r\n  0 =&gt; \"\u592a\u90ce\"\r\n  1 =&gt; \"\u6b21\u90ce\"\r\n]<\/strong><\/pre>\n<p style=\"text-align: right;\"><em>Laravel 7.8 \u4ee5\u964d<\/em><\/p>\n<h2>takeWhile()\u3067\u7279\u5b9a\u306e\u6761\u4ef6\u304c\u7d9a\u304f\u9650\u308a\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b<\/h2>\n<pre>$collection = collect(['\u592a\u90ce', '\u6b21\u90ce', '\u4e09\u90ce', '\u82b1\u5b50', '\u56db\u90ce']);\r\n\r\n$users = <strong>$collection-&gt;takeWhile(function ($item) {<\/strong>\r\n\r\n<strong>    return (Str::contains($item, '\u90ce')); \/\/ \ud83d\udc48 \u540d\u524d\u306b\u300c\u90ce\u300d\u304c\u5165\u3063\u3066\u3044\u308b\u9650\u308a\u7d9a\u304f<\/strong>\r\n\r\n<strong>})<\/strong>;\r\n\r\ndd($users-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>array:3 <strong>[\r\n  0 =&gt; \"\u592a\u90ce\"\r\n  1 =&gt; \"\u6b21\u90ce\"\r\n  2 =&gt; \"\u4e09\u90ce\"\r\n]<\/strong><\/pre>\n<p style=\"text-align: right;\"><em>Laravel 7.8 \u4ee5\u964d<\/em><\/p>\n<h2>toJson()\u3067JSON\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001Ajax\u901a\u4fe1\u306a\u3069\u306e\u305f\u3081\u306bJSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'id' =&gt; 1,\r\n    'name' =&gt; '\u9234\u6728',\r\n    'age' =&gt; 23\r\n]);\r\necho $collection-&gt;<strong>toJson()<\/strong>;<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>{\"id\":1,\"name\":\"\\u9234\\u6728\",\"age\":23}<\/pre>\n<p>\u3061\u306a\u307f\u306b<code>Laravel<\/code>\u306e<code>Collection<\/code>\u306f<code>toJson()<\/code>\u3092\u4f7f\u308f\u306a\u304f\u3068\u3082\u3001echo \u3067\u8868\u793a\u3057\u3066\u3084\u308c\u3070\u81ea\u52d5\u7684\u306bJSON\u5f62\u5f0f\u306b\u306a\u3063\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre>echo collect([\r\n    'id' =&gt; 1,\r\n    'name' =&gt; '\u9234\u6728',\r\n    'age' =&gt; 23\r\n]); \/\/ \uff08\u4e0a\u306e\u4f8b\u3068\u540c\u3058\u306b\u306a\u308a\u307e\u3059\uff09<\/pre>\n<h2>diff()\u3067\u6307\u5b9a\u30c7\u30fc\u30bf\u300c\u4ee5\u5916\u300d\u306e\u30c7\u30fc\u30bf\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p><code>Collection<\/code>\u306e\u4e2d\u304b\u3089\u6307\u5b9a\u3057\u305f\u3082\u306e\u300c<strong>\u4ee5\u5916<\/strong>\u300d\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$diff = $collection-&gt;<strong>diff(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d'])<\/strong>;\r\nprint_r($diff-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [3] =&gt; \u5c71\u672c\r\n    [4] =&gt; \u85e4\u539f\r\n)\r\n<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>diffAssoc()\u3067\u30ad\u30fc\u306e\u4e2d\u8eab\u304c\u9055\u3063\u3066\u3044\u308b\u3082\u306e\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u300c<strong>\u30ad\u30fc\u304c\u304a\u4e92\u3044\u5b58\u5728\u3057\u3066\u3044\u3066\u3001\u306a\u304a\u304b\u3064\u305d\u306e\u5024\u304c\u9055\u3063\u3066\u3044\u308b\u30c7\u30fc\u30bf<\/strong>\u300d\u3060\u3051\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[\r\n    'name' =&gt; '\u9234\u6728',\r\n    'age' =&gt; 20,\r\n    'todofuken' =&gt; '\u6771\u4eac\u90fd'\r\n]<\/strong>);\r\n$diff = $collection-&gt;<strong>diffAssoc([\r\n    'name' =&gt; '\u4f50\u85e4',\r\n    'age' =&gt; 15,\r\n    'todofuken' =&gt; '\u5927\u962a\u5e9c',\r\n    'height' =&gt; '170cm'\r\n])<\/strong>;\r\nprint_r($diff-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [name] =&gt; \u9234\u6728\r\n    [age] =&gt; 20\r\n)\r\n<\/pre>\n<h2>diffKeys()\u3067\u30ad\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u5143\u30c7\u30fc\u30bf\u3060\u3051\u306b\u5b58\u5728\u3059\u308b\u30ad\u30fc\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    'name' =&gt; '\u9234\u6728',<\/strong>\r\n<strong>    'age' =&gt; 20,<\/strong>\r\n<strong>    'todofuken' =&gt; '\u6771\u4eac\u90fd',<\/strong>\r\n<strong>    'height' =&gt; '170cm'<\/strong>\r\n<strong>]<\/strong>);\r\n$diff = $collection-&gt;<strong>diffKeys([<\/strong>\r\n<strong>    'name' =&gt; '\u4f50\u85e4',<\/strong>\r\n<strong>    'todofuken' =&gt; '\u5927\u962a\u5e9c'<\/strong>\r\n<strong>])<\/strong>;\r\nprint_r($diff-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>diffKeys()<\/code>\u306b\u542b\u307e\u308c\u3066\u3044\u306a\u3044<code>age<\/code>\u3068<code>height<\/code>\u3060\u3051\u304c\u53d6\u5f97\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[age]<\/strong> =&gt; 20\r\n    <strong>[height]<\/strong> =&gt; 170cm\r\n)\r\n<\/pre>\n<h2>each()\u3067\uff11\u884c\u305a\u3064\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p><code>Collection<\/code>\u306e\u4e2d\u8eab\u3092\uff11\u884c\u305a\u3064\u53d6\u308a\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u3064\u307e\u308a\u30eb\u30fc\u30d7\u3055\u305b\u307e\u3059\uff09<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$collection-&gt;<strong>each(function ($item, $key) {<\/strong>\r\n\r\n<strong>    echo $key .': '. $item; \/\/ \u9806\u306b\u30ad\u30fc\uff08\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff09\u3068\u5024\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059<\/strong>\r\n\r\n<strong>})<\/strong>;<\/pre>\n<p>\u3082\u3057\u9014\u4e2d\u3067\u7d42\u4e86\u3057\u305f\u3044\u5834\u5408\u306f<code>return false;<\/code>\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection-&gt;each(function ($item, $key) {\r\n\r\n    echo $key .': '. $item; \/\/ \u9806\u306b\u540d\u524d\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\r\n\r\n    <strong>return false;<\/strong>\r\n\r\n});<\/pre>\n<h2>eachSpread()\u3067\u30c7\u30fc\u30bf\u3092\u5909\u6570\u306b\u683c\u7d0d\u3055\u305b\u306a\u304c\u3089\uff11\u884c\u305a\u3064\u53d6\u5f97\u3059\u308b<\/h2>\n<p><a href=\"#each\">each()<\/a>\u306e\u3088\u3046\u306b\uff11\u884c\u305a\u3064\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059\u304c\u5c11\u3057\u305d\u306e\u3084\u308a\u65b9\u304c\u5c11\u3057\u9055\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    [1, '\u9234\u6728', 20],<\/strong>\r\n<strong>    [2, '\u4f50\u85e4', 22],<\/strong>\r\n<strong>    [3, '\u7530\u4e2d', 30]<\/strong>\r\n<strong>]<\/strong>);\r\n$collection-&gt;<strong>eachSpread(function($id, $name, $age)<\/strong>{\r\n\r\n    \/\/ \u4f55\u304b\u306e\u51e6\u7406\r\n\r\n});<\/pre>\n<p><code>function()<\/code>\u5185\u306e\u5f15\u6570\u304c\u305d\u308c\u305e\u308c\u306e\u914d\u5217\u306e\u4f4d\u7f6e\uff08\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff09\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002\u306a\u304a\u3001\u30ad\u30fc\u304c\u3042\u308b<code>Collection<\/code>\u3067\u306f\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>only()\u3067\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001<code>id<\/code>\u3068<code>name<\/code>\u3060\u3051\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20,  'height' =&gt; '170cm']);\r\n$filtered = $collection-&gt;<strong>only(['id', 'name'])<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[id]<\/strong> =&gt; 1\r\n    <strong>[name]<\/strong> =&gt; \u9234\u6728\r\n)\r\n<\/pre>\n<h2>except()\u3067\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u300c\u4ee5\u5916\u300d\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p><a href=\"#only\">only()<\/a>\u3068\u306f\u9006\u306b\u3001\u4f8b\u3048\u3070<code>id<\/code>\u3068<code>name<\/code>\u300c<strong>\u4ee5\u5916\u300d<\/strong>\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20,  'height' =&gt; '170cm']);\r\n$filtered = $collection-&gt;<strong>except(['id', 'name'])<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[age]<\/strong> =&gt; 20\r\n    <strong>[height]<\/strong> =&gt; 170cm\r\n)\r\n<\/pre>\n<h2>filter()\u3067\u6761\u4ef6\u306b\u5408\u3046\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u30c6\u30b9\u30c8\u306780\u70b9\u4ee5\u4e0a\u53d6\u3063\u305f\u4eba<\/strong>\u300d\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[70, 100, 35, 82]<\/strong>);\r\n$filtered = $collection-&gt;<strong>filter(function($value, $key){\r\n\r\n    return ($value &gt;= 80);\r\n\r\n})<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002\uff08\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09<\/p>\n<pre>Array\r\n(\r\n    <strong>[1]<\/strong> =&gt; 100\r\n    <strong>[3]<\/strong> =&gt; 82\r\n)\r\n<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001<code>function(){ ... }<\/code>\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001<strong>\u6761\u4ef6\u5f0f\u3067 false \u306b\u306a\u308b\u3082\u306e\u304c\u5168\u3066\u524a\u9664\u3055\u308c\u307e\u3059\u3002<\/strong><\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', null, false, '', 0, []]<\/strong>);\r\n$filtered = $collection-&gt;<strong>filter()<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n)\r\n<\/pre>\n<h2>first()\u3067\u6761\u4ef6\u306b\u5408\u3046\u6700\u521d\u306e\u30c7\u30fc\u30bf\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u30c6\u30b9\u30c8\u3067\u6700\u521d\u306b80\u70b9\u4ee5\u4e0a\u3060\u3063\u305f\u70b9\u6570<\/strong>\u300d\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([70, 50, <strong>82<\/strong>, 35]);\r\necho $collection-&gt;<strong>first(function ($value, $key) {<\/strong>\r\n    \r\n<strong>    return ($value &gt;= 80);<\/strong>\r\n    \r\n<strong>})<\/strong>; \/\/ 82<\/pre>\n<p>\u3082\u3061\u308d\u3093\u3001<code>function(){ ... }<\/code>\u3092\u6307\u5b9a\u3057\u306a\u3044\u5834\u5408\u306f\u4e00\u756a\u6700\u521d\u306e\u30c7\u30fc\u30bf\u304c\u53d6\u5f97\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([<strong>70<\/strong>, 50, 82, 35]);\r\necho $collection-&gt;<strong>first()<\/strong>; \/\/ 70<\/pre>\n<h2>firstWhere()\u3067\u6761\u4ef6\u306b\u5408\u3046\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p><a href=\"#where\">where()<\/a>\u306e\u3088\u3046\u306b\u300c\u6761\u4ef6\u306b\u5408\u3046<strong>\u6700\u521d\u306e\u30c7\u30fc\u30bf<\/strong>\u300d\u3092\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, <strong>'name' =&gt; '\u9234\u6728'<\/strong>, 'age' =&gt; 20],\r\n    ['id' =&gt; 2, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 22],\r\n    ['id' =&gt; 3, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 30]\r\n]);\r\n$array = $collection-&gt;<strong>firstWhere('name', '\u9234\u6728')<\/strong>;\r\nprint_r($array);<\/pre>\n<p>\u3082\u3061\u308d\u3093\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6bd4\u8f03\u6f14\u7b97\u5b50\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'age' =&gt; 18<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', <strong>'age' =&gt; 22<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'age' =&gt; 30<\/strong>]\r\n]);\r\n$array = $collection-&gt;<strong>firstWhere('age', '&gt;', 20)<\/strong>;<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u6761\u4ef6\u306b\u5408\u3046\u3082\u306e\u304c\u306a\u3044\u5834\u5408\u306f\u7d50\u679c\u306f\u3001<code>null<\/code>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>forPage()\u3092\u4f7f\u3063\u3066\u30da\u30fc\u30b8\u3054\u3068\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u300c<strong>\u73fe\u5728\u306e\u30da\u30fc\u30b8\u756a\u53f7<\/strong>\u300d\u3068\u300c<strong>\u4ef6\u6570<\/strong>\u300d\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$chunk = $collection-&gt;<strong>forPage(0, 3)<\/strong>;\r\nprint_r($chunk-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u8a00\u3046\u3068\u3001\u30c7\u30fc\u30bf\u306e\uff10\u4ef6\u76ee\uff08\uff1d\u9234\u6728\uff09\u304b\u3089\uff13\u4ef6\u5206\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u3001\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n)<\/pre>\n<h2>implode()\u3067\u30c7\u30fc\u30bf\u3092\u7d50\u5408\u3057\u305f\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u5024\u3092\u7d50\u5408\u3057\u3001\u6587\u5b57\u5217\u3068\u3057\u3066\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u540d\u524d\u3092\u300c\uff06\u300d\u3067\u7e4b\u3044\u3067\u7d50\u5408\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, <strong>'name' =&gt; '\u9234\u6728'<\/strong>, 'age' =&gt; 20],\r\n    ['id' =&gt; 2, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 23],\r\n    ['id' =&gt; 3, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 30]\r\n]);\r\necho $collection-&gt;<strong>implode('name', ' \uff06 ')<\/strong>; \/\/ \u9234\u6728 \uff06 \u4f50\u85e4 \uff06 \u7530\u4e2d<\/pre>\n<p>\u3082\u3057\u3001\uff11\u6b21\u5143\u914d\u5217\u306e\u5834\u5408\u306f\u30ad\u30fc\u306f\u5fc5\u8981\u306a\u304f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7d50\u5408\u6587\u5b57\u3060\u3051\u3092\u6307\u5b9a\u3059\u308b\u3060\u3051\u3067OK\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']);\r\necho $collection-&gt;<strong>implode(' \uff06 ')<\/strong>; \/\/ \u9234\u6728 \uff06 \u4f50\u85e4 \uff06 \u7530\u4e2d<\/pre>\n<h2>join()\u3067\u30c7\u30fc\u30bf\u3092\u7d50\u5408\u3057\u305f\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\uff08\u82f1\u6587\u6cd5\u7684\uff09<\/h2>\n<p>\u307b\u307c <a href=\"#implode\">implode()<\/a> \u3068\u540c\u3058\u3067\u5024\u3092\u7d50\u5408\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u3088\u308a\u82f1\u6587\u6cd5\u3092\u8003\u616e\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u901a\u5e38\u306f<code>implode()<\/code>\u3092\u4f7f\u3046\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>echo collect(['\u3042', '\u3044', '\u3046', '\u3048', '\u304a'])-&gt;<strong>join('\u3001')<\/strong>;<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u300c\u3042\u3001\u3044\u3001\u3046\u3001\u3048\u3001\u304a\u300d\u304c\u51fa\u529b\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u306e\u3067<code>implode()<\/code>\u3068\u5168\u304f\u540c\u3058\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u7b2c\uff12\u5f15\u6570\u3092\u4f7f\u3063\u305f\u5834\u5408\u306b\u9055\u3044\u304c\u82f1\u6587\u6cd5\u3078\u306e\u5bfe\u5fdc\u304c\u51fa\u307e\u3059\u3002<\/p>\n<pre>echo collect(['A', 'B', 'C', 'D', 'E'])-&gt;<strong>join(',', ' and ')<\/strong>;<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u51fa\u529b\u3055\u308c\u308b\u306e\u306f\u300c<strong>A,B,C,D and E<\/strong>\u300d\u3068\u6700\u5f8c\u306e\u3064\u306a\u304e\u90e8\u5206\u3060\u3051<code>and<\/code>\u304c\u9069\u7528\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u65e5\u672c\u8a9e\u3067\u306f\u3042\u307e\u308a\u4f7f\u3044\u3069\u3053\u308d\u306f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.8.4 \u4ee5\u964d<\/em><\/p>\n<h2>keys()\u3067\u30ad\u30fc\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304b\u3089\u00a0<code>id<\/code>\u3001\u00a0<code>name<\/code>\u3001<code>age<\/code>\u3068\u3044\u3046\u300c\u30ad\u30fc\u300d\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    <strong>'id'<\/strong> =&gt; 1,\r\n    <strong>'name'<\/strong> =&gt; '\u9234\u6728',\r\n    <strong>'age'<\/strong> =&gt; 20\r\n]);\r\n$keys = $collection-&gt;<strong>keys()<\/strong>;\r\nprint_r($keys-&gt;toArray()); \/\/ ['id', 'name', 'age']<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u591a\u91cd\u914d\u5217\u306e\u5834\u5408\u3067\u3082\uff11\u6b21\u5143\u306e\u30ad\u30fc\u304c\u5168\u3066\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    <strong>'id'<\/strong> =&gt; 1,\r\n    <strong>'name'<\/strong> =&gt; '\u9234\u6728',\r\n    <strong>'age'<\/strong> =&gt; 20,\r\n    <strong>'hobbies'<\/strong> =&gt; [\r\n        '\u30d4\u30a2\u30ce',\r\n        '\u8aad\u66f8'\r\n    ]\r\n]);\r\n$keys = <strong>$collection-&gt;keys();<\/strong><\/pre>\n<p>\uff08\u5b9f\u884c\u7d50\u679c\uff09<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; <strong>id<\/strong>\r\n    [1] =&gt; <strong>name<\/strong>\r\n    [2] =&gt; <strong>age<\/strong>\r\n    [3] =&gt; <strong>hobbies<\/strong>\r\n)<\/pre>\n<h2>values()\u3067\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff06\u30ad\u30fc\u3092\u521d\u671f\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\uff06\u30ad\u30fc\u3092\u521d\u671f\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    2 =&gt; '\u9234\u6728',<\/strong>\r\n<strong>    5 =&gt; '\u4f50\u85e4',<\/strong>\r\n<strong>    10 =&gt; '\u7530\u4e2d',<\/strong>\r\n<strong>    4 =&gt; '\u5c71\u672c',<\/strong>\r\n<strong>    'name' =&gt; '\u85e4\u539f'<\/strong>\r\n<strong>]<\/strong>);\r\n$new_collection = $collection-&gt;<strong>values()<\/strong>;\r\nprint_r($new_collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[0]<\/strong> =&gt; \u9234\u6728\r\n    <strong>[1]<\/strong> =&gt; \u4f50\u85e4\r\n    <strong>[2]<\/strong> =&gt; \u7530\u4e2d\r\n    <strong>[3]<\/strong> =&gt; \u5c71\u672c\r\n    <strong>[4]<\/strong> =&gt; \u85e4\u539f\r\n)<\/pre>\n<p><code>Collection<\/code>\u306b\u306f\u30ad\u30fc\u3092\u4fdd\u6301\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3082\u591a\u304f\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u30ad\u30fc\u3092\u306a\u3089\u3057\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300c-&gt;\u300d\u3067\u3064\u306a\u3052\u3066<code>values()<\/code>\u3092\u4f7f\u3046\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>$collection-&gt;slice(2, 2)-&gt;values();<\/strong><\/pre>\n<h2>last()\u3067\u6700\u5f8c\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4e00\u756a\u6700\u5f8c\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', <strong>'\u85e4\u539f'<\/strong>]);\r\necho $collection-&gt;<strong>last()<\/strong>; \/\/ \u85e4\u539f<\/pre>\n<p>\u307e\u305f\u3001<code>function(){ ... }<\/code>\u3092\u4f7f\u3048\u3070\u300c\u6761\u4ef6\u306b\u5408\u3046\u6700\u5f8c\u306e\u30c7\u30fc\u30bf\u300d\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 19],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 23],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 17],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', <strong>'age' =&gt; 25<\/strong>],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 19],\r\n]);\r\n$array = $collection-&gt;last(<strong>function($item, $key){<\/strong>\r\n\r\n<strong>    return ($item['age'] &gt;= 20); \/\/ 20\u6b73\u4ee5\u4e0a<\/strong>\r\n\r\n<strong>}<\/strong>);\r\nprint_r($array);<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u53d6\u5f97\u3067\u304d\u308b\u30c7\u30fc\u30bf\u306f\u3001\u5c71\u672c\u3055\u3093\u306e\u30c7\u30fc\u30bf\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [id] =&gt; 4\r\n    [name] =&gt; \u5c71\u672c\r\n    <strong>[age] =&gt; 25<\/strong>\r\n)<\/pre>\n<h2>reduce()\u3067\u30c7\u30fc\u30bf\u3092\u3072\u3068\u3064\u306b\u3057\u3066\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5024\u3092\u4f7f\u3063\u3066\uff11\u3064\u306e\u6587\u5b57\u5217\u3092\u3064\u304f\u308a\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\necho $collection-&gt;<strong>reduce(function($carry, $item){<\/strong>\r\n\r\n<strong>    return $item .'\u3002'. $carry;<\/strong>\r\n\r\n<strong>})<\/strong>; \/\/ \u7530\u4e2d\u3002\u4f50\u85e4\u3002\u9234\u6728\u3002<\/pre>\n<p>\u4e0a\u306e\u4f8b\u3067\u3001<code>$carry<\/code>\u306f\u6587\u5b57\u5217\u304c\u7d50\u5408\u3057\u3066\u3069\u3093\u3069\u3093\u9577\u304f\u306a\u3063\u3066\u3044\u304d\u307e\u3059\u3002\u6642\u9593\u9806\u306b\u4e2d\u8eab\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ol>\n<li><strong>\u9234\u6728\u3002<\/strong><\/li>\n<li><strong>\u4f50\u85e4\u3002\u9234\u6728\u3002<\/strong><\/li>\n<li><strong>\u7530\u4e2d\u3002\u4f50\u85e4\u3002\u9234\u6728\u3002<\/strong><\/li>\n<\/ol>\n<p>\u3082\u3057\u521d\u671f\u306e\u30c7\u30fc\u30bf\u3092\u6c7a\u3081\u3066\u304a\u304d\u305f\u3044\u5834\u5408\u306f\u7b2c\uff12\u5f15\u6570\u3078\u5165\u308c\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']);\r\necho $collection-&gt;reduce(function($carry, $item){\r\n\r\n    return $item .'\u3002'. $carry;\r\n\r\n}, <strong>'\u3067\u3059'<\/strong>); \/\/ \u7530\u4e2d\u3002\u4f50\u85e4\u3002\u9234\u6728\u3002<strong>\u3067\u3059<\/strong><\/pre>\n<h2>reject()\u3067\u6761\u4ef6\u306b\u5408\u308f\u306a\u3044\u3082\u306e\u3092\u9664\u5916\u3057\u3066\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>20\u6b73\u672a\u6e80\u306e\u30c7\u30fc\u30bf\u3092\u9664\u5916\u3059\u308b<\/strong>\u300d\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 15],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 23],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 19],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 16],\r\n]);\r\n$filtered = $collection-&gt;<strong>reject(function($values, $key){<\/strong>\r\n\r\n<strong>    return ($values['age'] &lt; 20); \/\/ 20\u6b73\u672a\u6e80\u306f\u300c\u9664\u5916\u300d<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            <strong>[age] =&gt; 23<\/strong>\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            [name] =&gt; \u7530\u4e2d\r\n            <strong>[age] =&gt; 20<\/strong>\r\n        )\r\n\r\n)\r\n<\/pre>\n<p>\u203b\u6ce8\u610f\u304c\u5fc5\u8981\u306a\u306e\u306f\u3001<strong>\u6761\u4ef6\u5f0f\u304c<\/strong><code>true<\/code><strong>\u306b\u306a\u308b\u3082\u306e\u306f\u9664\u5916\u3055\u308c\u308b\u3068\u3044\u3046\u70b9\u3067\u3059\u3002\u82f1\u5358\u8a9e\u306b\u99b4\u67d3\u307f\u304c\u306a\u3044\u3068\u76f4\u611f\u7684\u306b\u306f<\/strong><code>false<\/code><strong>\u306b\u3057\u3066\u3057\u307e\u3044\u305d\u3046\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u9006\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<h2>random()\u3067\u30e9\u30f3\u30c0\u30e0\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u30e9\u30f3\u30c0\u30e0\u306b\u540d\u524d\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u4f50\u85e4', '\u7530\u4e2d']);\r\necho $collection-&gt;<strong>random()<\/strong>; \/\/ \u4f8b\uff1a \u9234\u6728\uff08\u30e9\u30f3\u30c0\u30e0\u306b\u5909\u308f\u308b\uff09<\/pre>\n<p>\u307e\u305f\u3001\u30c7\u30fc\u30bf\u3092\u8907\u6570\u53d6\u5f97\u3059\u308b\u5834\u5408\u306f\u5f15\u6570\u306b\u4ef6\u6570\u3092\u5165\u308c\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u4f50\u85e4', '\u7530\u4e2d']);\r\n$names = $collection-&gt;<strong>random(3)<\/strong>;\r\nprint_r($names-&gt;toArray());<\/pre>\n<h2>unique()\u3067\u91cd\u8907\u3057\u306a\u3044\u5024\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u91cd\u8907\u3057\u306a\u3044\u540d\u524d\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\n$unique = $collection-&gt;<strong>unique()<\/strong>;\r\nprint_r($unique-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002\u5143\u30c7\u30fc\u30bf\u306e\u4e2d\u306b\u306f\u3001\u300c\u4f50\u85e4\u300d\u300c\u7530\u4e2d\u300d\u304c\u91cd\u8907\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u51e6\u7406\u5f8c\u306f\u3072\u3068\u3064\u3060\u3051\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n)<\/pre>\n<p>\u307e\u305f\u3001\u591a\u91cd\u914d\u5217\u306e\u5834\u5408\u306f\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u3084\u308b\u3053\u3068\u3067\u30e6\u30cb\u30fc\u30af\u306a\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, <strong>'name' =&gt; '\u9234\u6728'<\/strong>, 'age' =&gt; 16],\r\n    ['id' =&gt; 2, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 30],\r\n    ['id' =&gt; 3, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 27],\r\n    ['id' =&gt; 4, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 35],\r\n    ['id' =&gt; 5, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 23],\r\n]);\r\n$unique = $collection-&gt;<strong>unique('name')<\/strong>;\r\nprint_r($unique-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [id] =&gt; 1\r\n            <strong>[name] =&gt; \u9234\u6728<\/strong>\r\n            [age] =&gt; 16\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            <strong>[name] =&gt; \u4f50\u85e4<\/strong>\r\n            [age] =&gt; 30\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            <strong>[name] =&gt; \u7530\u4e2d<\/strong>\r\n            [age] =&gt; 27\r\n        )\r\n\r\n)<\/pre>\n<p>\u3055\u3089\u306b\u3001<code>function(){ ... }<\/code>\u3092\u4f7f\u3048\u3070\u3088\u308a\u8907\u96d1\u306a\u30e6\u30cb\u30fc\u30af\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u300c\u540d\u524d\u300d+\u300c\u5e74\u9f62\u300d\u3067\u51e6\u7406\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 16],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 30],\r\n    ['id' =&gt; 3, 'name' =&gt; <strong>'\u7530\u4e2d', 'age' =&gt; 27<\/strong>],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 35],\r\n    ['id' =&gt; 5, 'name' =&gt; <strong>'\u7530\u4e2d', 'age' =&gt; 27<\/strong>],\r\n]);\r\n$unique = $collection-&gt;unique(<strong>function($item){<\/strong>\r\n\r\n<strong>    return $item['name'] .'-'. $item['age']; <\/strong>\/\/ \u4f8b\uff1a\u9234\u6728-16\r\n\r\n<strong>}<\/strong>);\r\nprint_r($unique-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002\u540d\u524d\u3068\u5e74\u9f62\u304c\u3068\u3082\u306b\u540c\u3058\uff12\u3064\u306e\u300c\u7530\u4e2d\u300d\u3055\u3093\u306f\u91cd\u8907\u3057\u3066\u3044\u308b\u3068\u307f\u306a\u3055\u308c\uff11\u3064\u306e\u30c7\u30fc\u30bf\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [id] =&gt; 1\r\n            [name] =&gt; \u9234\u6728\r\n            [age] =&gt; 16\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            [age] =&gt; 30\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            [name] =&gt; \u7530\u4e2d\r\n            [age] =&gt; 27\r\n        )\r\n\r\n    [3] =&gt; Array\r\n        (\r\n            [id] =&gt; 4\r\n            [name] =&gt; \u4f50\u85e4\r\n            [age] =&gt; 35\r\n        )\r\n\r\n)<\/pre>\n<h2>uniqueStrict()\u3067\u91cd\u8907\u3057\u306a\u3044\u5024\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>unique()\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u91cd\u8907\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u969b\u306b\u3088\u308a\u53b3\u3057\u304f\u30c1\u30a7\u30c3\u30af\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5909\u6570\u306e\u578b\u307e\u3067\u30c1\u30a7\u30c3\u30af\u3059\u308b\u65b9\u6cd5\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>if(<strong>$a === $b<\/strong>) {}<\/pre>\n<p>\u203b\u4f7f\u3044\u65b9\u306f\u540c\u3058\u306a\u306e\u3067\u524d\u9805\u76ee\u306e<a href=\"#unique\">unique()<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>unwrap()\u3067Collection\u306e\u5143\u306b\u306a\u3063\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u53ef\u80fd\u3067\u3042\u308c\u3070\u5143\u306b\u306a\u3063\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre>$collection = Collection::<strong>unwrap(collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c']))<\/strong>;\r\nprint_r($collection);<\/pre>\n<h1>\u96c6\u8a08\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h1>\n<h2>count()\u3067\u30c7\u30fc\u30bf\u6570\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u3069\u308c\u3060\u3051\u306e\u8981\u7d20\u304c\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u5165\u3063\u3066\u3044\u308b\u304b\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']);\r\necho $collection-&gt;<strong>count()<\/strong>;  \/\/ 3<\/pre>\n<h2>countBy()\u3067\u500b\u5225\u306e\u30c7\u30fc\u30bf\u4ef6\u6570\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u540c\u3058\u5e74\u9f62\u304c\u4f55\u4eba\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3092\u96c6\u8a08\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$ages = [23, 27, 25, 20, 27, 27, 20]; \/\/ \u5e74\u9f62\r\n$counted = collect($ages)-&gt;<strong>countBy()<\/strong>;\r\nprint_r($counted-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [23] =&gt; 1\r\n    [27] =&gt; 3\r\n    [25] =&gt; 1\r\n    [20] =&gt; 2\r\n)<\/pre>\n<p>\u307e\u305f\u3001<code>countBy()<\/code>\u306f\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u52a0\u5de5\u3057\u305f\u5f8c\u306e\u30c7\u30fc\u30bf\u3067\u96c6\u8a08\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u5e74\u9f62\u304c25\u624d\u4ee5\u4e0a\u304b\u305d\u3046\u3067\u306a\u3044\u304b<\/strong>\u300d\u3067\u5206\u3051\u3066\u96c6\u8a08\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$ages = [23, 27, 25, 20, 27, 27, 20]; \/\/ \u5e74\u9f62\r\n$counted = collect($ages)-&gt;<strong>countBy(function($age) {<\/strong>\r\n\r\n<strong>    if($age &gt;= 25) {<\/strong>\r\n\r\n<strong>        return 'yes';<\/strong> \/\/ 25\u624d\u4ee5\u4e0a\u306e\u5834\u5408\r\n\r\n<strong>    } else {<\/strong>\r\n\r\n<strong>        return 'no';<\/strong>\/\/ 25\u624d\u672a\u6e80\u306e\u5834\u5408\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($counted-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [no] =&gt; 3\r\n    [yes] =&gt; 4\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.8.3 \u4ee5\u964d<\/em><\/p>\n<h2>avg(), average()\u3067\u30c7\u30fc\u30bf\u306e\u5e73\u5747\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u306e\u5e73\u5747\u5024\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([1, 2, 3, 4, 5]);\r\necho $collection-&gt;<strong>avg()<\/strong>; \/\/ 3<\/pre>\n<p>\u307e\u305f\u3001<code>avg()<\/code>\u306f\u30ad\u30fc\u304c\u5165\u3063\u305f\u30c7\u30fc\u30bf\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u5834\u5408\u306f\u5f15\u6570\u306b\u5e73\u5747\u5024\u3092\u53d6\u5f97\u3057\u305f\u3044\u30ad\u30fc\u3092\u5165\u308c\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect([\r\n    ['name' =&gt; '\u9234\u6728', <strong>'age' =&gt; 20<\/strong>],\r\n    ['name' =&gt; '\u4f50\u85e4', <strong>'age' =&gt; 22<\/strong>],\r\n    ['name' =&gt; '\u7530\u4e2d', <strong>'age' =&gt; 30<\/strong>]\r\n]);\r\necho $collection-&gt;<strong>avg('age')<\/strong>; \/\/ 24<\/pre>\n<p>\u203b<code>avg()<\/code>\u3068<code>average()<\/code>\u306f\u540c\u3058\u3082\u306e\u3067\u3059\u3002<\/p>\n<h2>max()\u3067\u6700\u5927\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u306e\u4e2d\u304b\u3089\u6700\u5927\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([1, 2, 3, 4, 5]);\r\necho $collection-&gt;<strong>max()<\/strong>; \/\/ 5<\/pre>\n<p>\u307e\u305f\u3001\u30ad\u30fc\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['name' =&gt; '\u9234\u6728', <strong>'age'<\/strong> =&gt; 20],\r\n    ['name' =&gt; '\u4f50\u85e4', <strong>'age'<\/strong> =&gt; 22],\r\n    ['name' =&gt; '\u7530\u4e2d', <strong>'age'<\/strong> =&gt; 30]\r\n]);\r\necho $collection-&gt;max(<strong>'age'<\/strong>); \/\/ 30<\/pre>\n<h2>min()\u3067\u6700\u5c0f\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u306e\u4e2d\u304b\u3089\u6700\u5c0f\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([1, 2, 3, 4, 5]);\r\necho $collection-&gt;<strong>min()<\/strong>; \/\/ 1<\/pre>\n<p>\u307e\u305f\u3001<a href=\"#max\">max()<\/a>\u3068\u540c\u3058\u304f\u30ad\u30fc\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['name' =&gt; '\u9234\u6728', <strong>'age'<\/strong> =&gt; 20],\r\n    ['name' =&gt; '\u4f50\u85e4', <strong>'age'<\/strong> =&gt; 22],\r\n    ['name' =&gt; '\u7530\u4e2d', <strong>'age'<\/strong> =&gt; 30]\r\n]);\r\necho $collection-&gt;min(<strong>'age'<\/strong>); \/\/ 20<\/pre>\n<h2>sum()\u3067\u5408\u8a08\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u5168\u30c7\u30fc\u30bf\u306e\u5408\u8a08\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[1, 2, 3, 4, 5]<\/strong>);\r\necho $collection-&gt;<strong>sum(); \/\/ 15<\/strong><\/pre>\n<p>\u307e\u305f\u3001\u591a\u91cd\u914d\u5217\u306e\u5834\u5408\u306f\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u5408\u8a08\u5024\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u70b9\u6570\u306e\u5408\u8a08\u5024\u3092\u53d6\u5f97\u3059\u308b\u4f8b\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'score' =&gt; 83<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', <strong>'score' =&gt; 67<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'score' =&gt; 98<\/strong>],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', <strong>'score' =&gt; 32<\/strong>],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', <strong>'score' =&gt; 45<\/strong>],\r\n]);\r\necho $collection-&gt;<strong>sum('score')<\/strong>; \/\/ 325<\/pre>\n<p>\u3055\u3089\u306b\u3001<code>function(){ ... }<\/code>\u3092\u4f7f\u3046\u3068\u3088\u308a\u8907\u96d1\u306a\u5408\u8a08\u5024\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u70b9\u6570\u306e2\u4e57\u3092\u5408\u8a08\u3057\u305f\u5024\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'score' =&gt; 83],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'score' =&gt; 67],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'score' =&gt; 98],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'score' =&gt; 32],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'score' =&gt; 45],\r\n]);\r\necho $collection-&gt;sum(<strong>function($item){<\/strong>\r\n\r\n<strong>    return pow($item['score'], 2);<\/strong>\r\n\r\n<strong>}<\/strong>); \/\/ 24031<\/pre>\n<h2>median()\u3067\u4e2d\u592e\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u306e<a href=\"https:\/\/ja.wikipedia.org\/wiki\/\u4e2d\u592e\u5024\" target=\"_blank\" rel=\"noopener noreferrer\">\u4e2d\u592e\u5024<\/a>\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([1, 3, 5]);\r\necho $collection-&gt;<strong>median()<\/strong>; \/\/ 3<\/pre>\n<p>\u306a\u304a\u3001\u591a\u91cd\u914d\u5217\u306e\u5834\u5408\u306f\u30ad\u30fc\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4f7f\u3044\u65b9\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['age' =&gt; 17],\r\n    ['age' =&gt; 23],\r\n    ['age' =&gt; 30],\r\n    ['age' =&gt; 19],\r\n    ['age' =&gt; 5],\r\n]);\r\necho $collection-&gt;<strong>median('age')<\/strong>; \/\/ 19<\/pre>\n<h2>mode()\u3067\u6700\u983b\u5024\uff08\u30e2\u30fc\u30c9\uff09\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u304b\u3089<a href=\"https:\/\/ja.wikipedia.org\/wiki\/\u6700\u983b\u5024\" target=\"_blank\" rel=\"noopener noreferrer\">\u6700\u983b\u5024<\/a>\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([1, 1, 2, 4]);\r\nprint_r(<strong>$collection-&gt;mode()<\/strong>);<\/pre>\n<p>\u307e\u305f\u3001\u591a\u91cd\u914d\u5217\u306e\u5834\u5408\u306f\u30ad\u30fc\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    [<strong>'age'<\/strong> =&gt; 10],\r\n    [<strong>'age'<\/strong> =&gt; 10],\r\n    [<strong>'age'<\/strong> =&gt; 20],\r\n    [<strong>'age'<\/strong> =&gt; 40]\r\n]);\r\nprint_r($collection-&gt;<strong>mode('age')<\/strong>);<\/pre>\n<h2>nth()\u3067n\u756a\u76ee\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u3042\u308b\u500d\u6570\u3054\u3068\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u53d6\u5f97\u3057\u307e\u3059\u3002\uff08\u3064\u307e\u308a\u30a4\u30f3\u30c7\u30c3\u30af\u30b9<code>0<\/code>\u756a\u76ee\u3082\u5165\u308a\u307e\u3059\uff09<\/p>\n<pre>$collection = collect([<strong>1<\/strong>, 2, 3, <strong>4<\/strong>, 5, 6, <strong>7<\/strong>, 8, 9, <strong>10<\/strong>]);\r\n$new_collection = $collection-&gt;<strong>nth(3)<\/strong>;\r\nprint_r($new_collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3057\u305f\u3082\u306e\u304c\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; 1\r\n    [1] =&gt; 4\r\n    [2] =&gt; 7\r\n    [3] =&gt; 10\r\n)<\/pre>\n<h2>search()\u3067\u6307\u5b9a\u3057\u305f\u5024\u306e\u30ad\u30fc\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u305f\u304f\u3055\u3093\u3042\u308b\u540d\u524d\u306e\u4e2d\u304b\u3089\u300c<strong>\u7530\u4e2d<\/strong>\u300d\u3055\u3093\u304c\u4f55\u756a\u76ee\u304b\u3092\u77e5\u308a\u305f\u3044\u3068\u304d\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\necho $collection-&gt;<strong>search('\u7530\u4e2d')<\/strong>; \/\/ 2<\/pre>\n<p>\u3053\u306e\u5834\u5408\u306f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3001\u3064\u307e\u308a\u30bc\u30ed\u304b\u3089\u59cb\u307e\u308b\u6570\u5b57\u306b\u306a\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u5024\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306f<code>false<\/code>\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$collection-&gt;<strong>search('\u52a0\u85e4')<\/strong>; \/\/ false<\/pre>\n<p>\u3055\u3089\u306b\u3001\u300c\u30c7\u30fc\u30bf\u306e\u578b\u300d\u307e\u3067\u8003\u616e\u3057\u305f\u6bd4\u8f03\u3092\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7b2c2\u5f15\u6570\u3092<code>true<\/code>\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([1, 2, 3, 4, 5]);\r\necho $collection-&gt;<strong>search('1', true)<\/strong>; \/\/ \u6587\u5b57\u5217\u306a\u306e\u3067\u898b\u3064\u304b\u3089\u306a\u3044<\/pre>\n<p>\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a<code>if<\/code>\u6587\u3092\u601d\u3044\u6d6e\u304b\u3079\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre>if(<strong>$a === $b<\/strong>) {}<\/pre>\n<p>\u306a\u304a\u3001<code>search()<\/code>\u306b\u306f<code>function(){ ... }<\/code>\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u307020\u6b73\u4ee5\u4e0a\u306e\u30c7\u30fc\u30bf\u3092\u63a2\u3059\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 15],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; <strong>23<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 19],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 16],\r\n]);\r\necho $collection-&gt;<strong>search(function($item, $key){<\/strong>\r\n\r\n<strong>    return ($item['age'] &gt;= 20); \/\/ 20\u624d\u4ee5\u4e0a<\/strong>\r\n\r\n<strong>})<\/strong>; \/\/ 1\uff082\u756a\u3081\u306e\u30c7\u30fc\u30bf\uff09<\/pre>\n<h2>duplicates()\u3067\u91cd\u8907\u3059\u308b\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u3042\u308b\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u4e2d\u306e\u300c<strong>\u3069\u306e\u4f4d\u7f6e\u3067\u91cd\u8907\u3057\u305f\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u304b<\/strong>\u300d\u3092\u96c6\u8a08\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$names = [\r\n    '\u5c71\u7530\u592a\u90ce', \/\/ 0\r\n    '\u4f50\u85e4\u6b21\u90ce', \/\/ 1\r\n    '\u4f50\u85e4\u6b21\u90ce', \/\/ 2\r\n    '\u5c71\u7530\u592a\u90ce', \/\/ 3\r\n    '\u7530\u4e2d\u4e09\u90ce', \/\/ 4\r\n    '\u5c71\u7530\u592a\u90ce', \/\/ 5\r\n];\r\n$collection = collect($names)-&gt;<strong>duplicates()<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u91cd\u8907\u304c\u898b\u3064\u304b\u308b\u5834\u6240\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong>\u5c71\u7530\u592a\u90ce\uff1a<\/strong> \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7\u300c3\u300d\u300c5\u300d<\/li>\n<li><strong>\u4f50\u85e4\u6b21\u90ce\uff1a<\/strong> \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7\u300c2\u300d<\/li>\n<li><strong>\u7530\u4e2d\u4e09\u90ce\uff1a<\/strong> \uff08\u91cd\u8907\u306a\u3057\uff09<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[2]<\/strong> =&gt; \u4f50\u85e4\u6b21\u90ce\r\n    <strong>[3]<\/strong> =&gt; \u5c71\u7530\u592a\u90ce\r\n    <strong>[5]<\/strong> =&gt; \u5c71\u7530\u592a\u90ce\r\n)<\/pre>\n<p>\u307e\u305f\u3001<code>duplicates()<\/code>\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u3066\u3001\u4ee5\u4e0b\u306e\u5834\u5408\u306f\u5f15\u6570\u306b\u30bf\u30fc\u30b2\u30c3\u30c8\u306b\u3057\u305f\u3044\u30ad\u30fc\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<pre>$users = [\r\n    ['id' =&gt; 1, 'name' =&gt; '\u5c71\u7530\u592a\u90ce', 'email' =&gt; 'taro@example.com'], \/\/ 0\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4\u6b21\u90ce', 'email' =&gt; 'jiro@example.com'], \/\/ 1\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4\u6b21\u90ce', 'email' =&gt; 'jiro@example.com'], \/\/ 2\r\n    ['id' =&gt; 1, 'name' =&gt; '\u5c71\u7530\u592a\u90ce', 'email' =&gt; 'taro@example.com'], \/\/ 3\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d\u4e09\u90ce', 'email' =&gt; 'saburo@example.com'], \/\/ 4\r\n    ['id' =&gt; 1, 'name' =&gt; '\u5c71\u7530\u592a\u90ce', 'email' =&gt; 'taro@example.com'], \/\/ 5\r\n];\r\n$collection = collect($users)-&gt;<strong>duplicates('name')<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3001\u5148\u307b\u3069\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.8.12 \u4ee5\u964d<\/em><\/p>\n<h2>duplicatesStrict()\u3067\u3088\u308a\u53b3\u683c\u306b\u91cd\u8907\u3059\u308b\u5024\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u307b\u307c<a href=\"#duplicates\">duplicates()<\/a>\u3068\u540c\u3058\u3067\u3059\u304c\u3001\u96c6\u8a08\u3059\u308b\u969b\u306b\u30c7\u30fc\u30bf\u306e\u300c\u578b\u300d\u3082\u540c\u3058\u3067\u306a\u3044\u3068\u96c6\u8a08\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u4f8b\u3092\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>$numbers = <strong>[1, 2, '1', 3, 2]<\/strong>;\r\n$collection = collect($numbers)-&gt;<strong>duplicatesStrict()<\/strong>;<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001<code>1<\/code>\u306f\uff12\u3064\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u4e00\u65b9\u306f\u300c\u6570\u5024\u300d\u3067\u3082\u3046\u4e00\u3064\u306f\u300c\u6587\u5b57\u5217\u300d\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u3001<code>1<\/code>\u306f\u91cd\u8907\u3057\u305f\u3068\u306f<strong>\u307f\u306a\u3055\u308c\u307e\u305b\u3093\u3002<\/strong><\/p>\n<p>\u7d50\u679c\u3068\u3057\u3066\u3001\u91cd\u8907\u3059\u308b\u306e\u306f<code>2<\/code>\u306e\u307f\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [4] =&gt; 2\r\n)<\/pre>\n<p>\u305d\u306e\u4ed6\u306e\u4f7f\u3044\u65b9\u306f<a href=\"#duplicates\">duplicates()<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.8.12 \u4ee5\u964d<\/em><\/p>\n<h1>\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u30fb\u524a\u9664\u30fb\u4f5c\u6210\u3059\u308b<\/h1>\n<h2>push()\u3067\u30c7\u30fc\u30bf\u3092\u6700\u5f8c\u306b\u8ffd\u52a0\u3059\u308b<\/h2>\n<p>\u6700\u5f8c\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u8d64', '\u9752']);\r\n$collection-&gt;<strong>push('\u9ec4\u8272')<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u8d64\r\n    [1] =&gt; \u9752\r\n    <strong>[2] =&gt; \u9ec4\u8272<\/strong>\r\n)<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u5f15\u6570\u306b\u914d\u5217\u3092\u6307\u5b9a\u3059\u308b\u3068\u305d\u306e\u307e\u307e\u914d\u5217\u69cb\u9020\u304c\u6b8b\u308b\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>$collection = collect(['\u8d64']);\r\n$collection-&gt;<strong>push(['\u9752', '\u9ec4\u8272'])<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<pre>Array\r\n(\r\n    [0] =&gt; \u8d64\r\n    [1] =&gt; <strong>Array<\/strong>\r\n<strong>    (<\/strong>\r\n<strong>        [0] =&gt; \u9752<\/strong>\r\n<strong>        [1] =&gt; \u9ec4\u8272<\/strong>\r\n<strong>    )<\/strong>\r\n\r\n)<\/pre>\n<p>\u305d\u306e\u305f\u3081\u3001\u4e00\u6c17\u306b\u8907\u6570\u306e\u30c7\u30fc\u30bf\u3092\u540c\u3058\u6b21\u5143\u306b\u30c7\u30fc\u30bf\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306f <a href=\"#concat\">concat()<\/a> \u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>put()\u3067\u30ad\u30fc\u3068\u5024\u3092\u8ffd\u52a0\u3059\u308b<\/h2>\n<p>\u30ad\u30fc\u3068\u5024\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['id' =&gt; 1, 'name' =&gt; '\u9234\u6728']<\/strong>);\r\n$collection-&gt;<strong>put('age', 20)<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [id] =&gt; 1\r\n    [name] =&gt; \u9234\u6728\r\n    <strong>[age] =&gt; 20<\/strong>\r\n)<\/pre>\n<p>\u306a\u304a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['id' =&gt; 1, 'name' =&gt; '\u9234\u6728']);\r\n<strong>$collection['age'] = 20;<\/strong> \/\/ \u3053\u308c\u3067\u3082\u8ffd\u52a0\u3067\u304d\u308b<\/pre>\n<h2>concat()\u3067\u30c7\u30fc\u30bf\u3092\u6700\u5f8c\u306b\u8ffd\u52a0\u3059\u308b<\/h2>\n<p>\u4e00\u756a\u6700\u5f8c\u306b\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u305f\u3060\u3057\u3001\uff11\u6b21\u5143\u914d\u5217\u3068\u3057\u3066\u8ffd\u52a0\u3055\u308c\u308b\uff09<\/p>\n<pre>$collection = collect(['\u8d64']);\r\n$concatenated = $collection-&gt;<strong>concat(['\u9752'])<\/strong>-&gt;<strong>concat(['\u9ec4\u8272', '\u767d'])<\/strong>;\r\nprint_r($concatenated-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u8d64\r\n    [1] =&gt; \u9752\r\n    [2] =&gt; \u9ec4\u8272\r\n    [3] =&gt; \u767d\r\n)<\/pre>\n<p>\u203b<a href=\"#push\">push()<\/a>\u3067\u3082\u4e00\u756a\u6700\u5f8c\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u5f15\u6570\u304c\u914d\u5217\u306e\u5834\u5408\u3001\u305d\u306e\u307e\u307e\u914d\u5217\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002\uff08\u3064\u307e\u308a\u591a\u6b21\u5143\u914d\u5217\u306b\u306a\u308a\u307e\u3059\uff09<\/p>\n<h2>combine()\u3067\u30ad\u30fc\u3068\u5024\u3092\u7d50\u5408\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u540d\u524d\uff08<code>name<\/code>\uff09\u3068\u90fd\u9053\u5e9c\u770c\uff08<code>todofuken<\/code>\uff09\u306e\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u5834\u5408\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect(<strong>['name', 'todofuken']<\/strong>);\r\n$combined = $collection-&gt;<strong>combine(['\u9234\u6728\u592a\u90ce', '\u6771\u4eac\u90fd'])<\/strong>;\r\nprint_r($combined-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [<strong>name<\/strong>] =&gt; <strong>\u9234\u6728\u592a\u90ce<\/strong>\r\n    [<strong>todofuken<\/strong>] =&gt; <strong>\u6771\u4eac\u90fd\r\n)<\/strong><\/pre>\n<p>\u203b\u30ad\u30fc\u3068\u5024\u306e\u4ef6\u6570\u304c\u9055\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306e\u3067\u6c17\u3092\u3064\u3051\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>forget()\u3067\u30ad\u30fc\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u524a\u9664\u3059\u308b<\/h2>\n<p>\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'id' =&gt; 1,\r\n    'name' =&gt; '\u9234\u6728',\r\n    'age' =&gt; 25\r\n]);\r\n$collection-&gt;<strong>forget('name')<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [id] =&gt; 1\r\n    [age] =&gt; 25\r\n)\r\n<\/pre>\n<p>\u307e\u305f\u3001\u524a\u9664\u3057\u305f\u3044\u30ad\u30fc\u306f\u914d\u5217\u3092\u4f7f\u3063\u3066\u4e00\u6c17\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection-&gt;<strong>forget(['name', 'age'])<\/strong>;<\/pre>\n<h2>pull()\u3067\u6307\u5b9a\u30ad\u30fc\u3092\u524a\u9664\u3059\u308b<\/h2>\n<p>\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20]<\/strong>);\r\n$collection-&gt;<strong>pull('name')<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [id] =&gt; 1\r\n    [age] =&gt; 20\r\n)<\/pre>\n<p>\u3061\u306a\u307f\u306b<code>forget()<\/code>\u3068\u540c\u3058\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u304c\u3001<code>pull()<\/code>\u306f<strong>\u524a\u9664\u3057\u305f\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002<\/strong><\/p>\n<pre>$collection = collect(['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20]);\r\necho $collection-&gt;<strong>pull('name')<\/strong>; \/\/ <strong>\u9234\u6728<\/strong><\/pre>\n<h2>intersect()\u3067\u5b58\u5728\u3057\u306a\u3044\u5024\u3092\u524a\u9664\u3059\u308b<\/h2>\n<p>\u6307\u5b9a\u3057\u305f\u5024\u306b\u306a\u3044\u3082\u306e\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$intersect = $collection-&gt;<strong>intersect(['\u9234\u6728', '\u7530\u4e2d', '\u5c71\u672c'])<\/strong>;\r\nprint_r($intersect-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002\uff08\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre>Array\r\n(\r\n<strong>    [0] =&gt; \u9234\u6728\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u5c71\u672c<\/strong>\r\n)\r\n<\/pre>\n<h2>intersectByKeys()\u3067\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u3092\u524a\u9664\u3059\u308b<\/h2>\n<p><a href=\"#intersect\">intersect()<\/a>\u306e\u5834\u5408\u306f\u3001\u5024\u3092\u4f7f\u3063\u3066\u5b58\u5728\u3057\u306a\u3044\u3082\u306e\u3092\u524a\u9664\u3057\u307e\u3057\u305f\u304c<code>intersectByKeys()<\/code>\u306f\u3001\u914d\u5217\u3092\u4f7f\u3063\u3066\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'id' =&gt; 1, \r\n    <strong>'name' =&gt; '\u9234\u6728',<\/strong> \r\n    'age' =&gt; 20\r\n]);\r\n$intersect = $collection-&gt;<strong>intersectByKeys(['name' =&gt; '\u4f50\u85e4'])<\/strong>;\r\nprint_r($intersect-&gt;toArray());<\/pre>\n<p>\u4e0a\u306e\u4f8b\u3067\u306f\u3001\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u300c<strong>name<\/strong>\u300d\u4ee5\u5916\u306e\u30c7\u30fc\u30bf\u304c\u5168\u3066\u524a\u9664\u3055\u308c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [name] =&gt; \u9234\u6728\r\n)<\/pre>\n<h2>merge()\u3067\uff12\u3064\u306e\u30c7\u30fc\u30bf\u3092\u5408\u4f53\u3055\u305b\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001<code>id<\/code>\u3001<code>name<\/code>\u3060\u3051\u30c7\u30fc\u30bf\u3068<code>age<\/code>\u3060\u3051\u306e\u30c7\u30fc\u30bf\u3092\u5408\u4f53\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['id' =&gt; 1, 'name' =&gt; '\u9234\u6728']<\/strong>);\r\n$merged = $collection-&gt;<strong>merge(['age' =&gt; 20])<\/strong>;\r\nprint_r($merged-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [id] =&gt; 1\r\n    [name] =&gt; \u9234\u6728\r\n    [age] =&gt; 20\r\n)<\/pre>\n<p>\u203b\u3061\u306a\u307f\u306b\u30ad\u30fc\u304c\u91cd\u8907\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3067\u4e0a\u66f8\u304d\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u3082\u3061\u308d\u3093\u30ad\u30fc\u304c\u3064\u3044\u3066\u3044\u306a\u3044\u914d\u5217\u3067\u3082<code>merge()<\/code>\u306f\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\n$merged = $collection-&gt;<strong>merge(['\u5c71\u672c', '\u85e4\u539f'])<\/strong>;<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u5c71\u672c\r\n    [4] =&gt; \u85e4\u539f\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.8.28 \u4ee5\u964d<\/em><\/p>\n<h2>mergeRecursive()\u3067\uff12\u3064\u306e\u30c7\u30fc\u30bf\u3092\u91cd\u8907\u3059\u308b\u30ad\u30fc\u3067\u5408\u4f53\u3055\u305b\u308b<\/h2>\n<p><a href=\"#merge\">merge()<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u300c\u91cd\u8907\u30ad\u30fc\u3092\u4f7f\u3063\u3066\u5408\u4f53\u300d\u3055\u305b\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$user_1 = ['id' =&gt; 1, 'name' =&gt; '\u5c71\u7530\u592a\u90ce'];\r\n$user_2 = ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4\u6b21\u90ce', 'age' =&gt; 20];\r\n$merged = collect($user_1)-&gt;<strong>mergeRecursive($user_2)<\/strong>;\r\n\r\nprint_r($merged-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u30ad\u30fc\u306e\u3046\u3061<code>id<\/code>\u3068<code>name<\/code>\u306f\u91cd\u8907\u3059\u308b\u306e\u3067\u914d\u5217\u3068\u3057\u3066\u5408\u4f53\u3055\u308c\u307e\u3059\u3002\u305f\u3060\u3057\u3001<code>age<\/code>\u306f\u91cd\u8907\u3057\u306a\u3044\u306e\u3067\u914d\u5217\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [id] =&gt; Array\r\n    (\r\n        [0] =&gt; 1\r\n        [1] =&gt; 2\r\n    )\r\n    \r\n    [name] =&gt; Array\r\n    (\r\n        [0] =&gt; \u5c71\u7530\u592a\u90ce\r\n        [1] =&gt; \u4f50\u85e4\u6b21\u90ce\r\n    )\r\n    \r\n    [age] =&gt; 20\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.8.28 \u4ee5\u964d<\/em><\/p>\n<h2>union()\u3067\uff12\u3064\u306e\u30c7\u30fc\u30bf\u3092\u5408\u4f75\u3059\u308b<\/h2>\n<p><a href=\"#merge\">merge()<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u9055\u3044\u306f\u300c<strong>\u91cd\u8907\u3059\u308b\u30c7\u30fc\u30bf\u306e\u53d6\u308a\u6271\u3044\u65b9<\/strong>\u300d\u3067\u3059\u3002<code>union()<\/code>\u306f\u3001\u3059\u3067\u306b\u30ad\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u5143\u306e\u30c7\u30fc\u30bf\u304c\u512a\u5148\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['id' =&gt; 1, 'name' =&gt; '\u9234\u6728']<\/strong>);\r\n$union = $collection-&gt;<strong>union(['age' =&gt; 23, 'id' =&gt; 2])<\/strong>;\r\nprint_r($union-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<code>id<\/code>\u304c\u91cd\u8907\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5143\u306e<code>1<\/code>\u304c\u512a\u5148\u3055\u308c\u3066\u6b8b\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[id] =&gt; 1<\/strong>\r\n    [name] =&gt; \u9234\u6728\r\n    [age] =&gt; 23\r\n)\r\n<\/pre>\n<h2>prepend()\u3067\u6700\u521d\u306e\u4f4d\u7f6e\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b<\/h2>\n<p>\u5148\u982d\u306b\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u4f50\u85e4', '\u7530\u4e2d']);\r\n$collection-&gt;<strong>prepend('\u9ad8\u6a4b')<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002\uff08\u203b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u5024\u306f\u4fdd\u6301\u3055\u308c\u307e\u305b\u3093\u3002\uff09<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9ad8\u6a4b\r\n    [1] =&gt; \u9234\u6728\r\n    [2] =&gt; \u4f50\u85e4\r\n    [3] =&gt; \u7530\u4e2d\r\n    [4] =&gt; \u4f50\u85e4\r\n    [5] =&gt; \u7530\u4e2d\r\n)\r\n<\/pre>\n<p>\u307e\u305f\u3001\u9023\u60f3\u914d\u5217\u306b\u8ffd\u52a0\u3059\u308b\u5834\u5408\u306f\u7b2c\uff12\u5f15\u6570\u306b\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['name' =&gt; '\u9234\u6728', 'age' =&gt; 20]);\r\n$collection-&gt;<strong>prepend(1, 'id')<\/strong>;<\/pre>\n<h2>shift()\u3067\u6700\u521d\u306e\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b<\/h2>\n<p>\u4e00\u756a\u6700\u521d\u306e\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\n$collection-&gt;<strong>shift()<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u524a\u9664\u3055\u308c\u305f\u300c\u9234\u6728\u300d\u4ee5\u5916\u306e\uff14\u4eba\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u4f50\u85e4\r\n    [1] =&gt; \u7530\u4e2d\r\n    [2] =&gt; \u4f50\u85e4\r\n    [3] =&gt; \u7530\u4e2d\r\n)\r\n<\/pre>\n<p>\u307e\u305f\u3001<code>shift()<\/code>\u306e\u8fd4\u308a\u5024\u306f\u524a\u9664\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>echo $collection-&gt;<strong>shift()<\/strong>; \/\/ \u9234\u6728<\/pre>\n<h2>pop()\u3067\u6700\u5f8c\u306e\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b<\/h2>\n<p>\u4e00\u756a\u6700\u5f8c\u306e\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\n<strong>$collection-&gt;pop()<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u524a\u9664\u3055\u308c\u305f\u300c\u7530\u4e2d\u300d\u4ee5\u5916\u306e\uff14\u4eba\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u4f50\u85e4\r\n)<\/pre>\n<p>\u307e\u305f\u3001<code>pop()<\/code>\u306e\u8fd4\u308a\u5024\u306f\u524a\u9664\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>echo <strong>$collection-&gt;pop()<\/strong>; \/\/ \u7530\u4e2d<\/pre>\n<h2>times()\u3067\u7279\u5b9a\u306e\u56de\u6570\u5206\u3060\u3051\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c\u305d\u306e\uff11\u300d\u301c\u300c\u305d\u306e10\u300d\u3068\u3044\u3046\u30c7\u30fc\u30bf\u3092\u4f5c\u308b\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = Collection::<strong>times(10, function($number) {<\/strong>\r\n\r\n<strong>    return '\u305d\u306e'. $number;<\/strong>\r\n\r\n<strong>}<\/strong>);\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u7b2c\uff11\u5f15\u6570\u304c\u30c7\u30fc\u30bf\u306e\u4ef6\u6570\u3067\u3001\u7b2c\uff12\u5f15\u6570\u306f\u305d\u306e\u30c7\u30fc\u30bf\u3092\u4f5c\u308b\u95a2\u6570\u3067\u3059\u3002<code>Seeder<\/code>\u3067\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u4f5c\u308b\u306e\u306b\u91cd\u5b9d\u3059\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>wrap()\u3067Collection\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u53ef\u80fd\u3067\u3042\u308c\u3070<code>Collection<\/code>\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = Collection::<strong>wrap(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d'])<\/strong>;<\/pre>\n<h2>zip()\u3067\u591a\u91cd\u914d\u5217\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u5143\u30c7\u30fc\u30bf\u306b\u305d\u308c\u305e\u308c\u65b0\u3057\u3044\u5024\u3092\u8ffd\u52a0\u3057\u3001\u591a\u91cd\u914d\u5217\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u751f\u5f92\u30c7\u30fc\u30bf\u3068\u30c6\u30b9\u30c8\u7d50\u679c\u3092\u7d50\u3073\u3064\u3051\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\n$zipped = $collection-&gt;<strong>zip([80, 73, 23])<\/strong>;\r\nprint_r($zipped-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            <strong>[0] =&gt; \u9234\u6728\r\n            [1] =&gt; 80<\/strong>\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            <strong>[0] =&gt; \u4f50\u85e4\r\n            [1] =&gt; 73<\/strong>\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            <strong>[0] =&gt; \u7530\u4e2d\r\n            [1] =&gt; 23<\/strong>\r\n        )\r\n\r\n)\r\n<\/pre>\n<h1>\u30c7\u30fc\u30bf\u306e\u69cb\u9020\u3084\u5024\u3092\u5909\u66f4\u3059\u308b<\/h1>\n<h2>chunk()\u3067\u3042\u308b\u4ef6\u6570\u3054\u3068\u306b\u5206\u5272\u3059\u308b<\/h2>\n<p>\u305f\u304f\u3055\u3093\u3042\u308b\u30c7\u30fc\u30bf\u3092\u7279\u5b9a\u306e\u4ef6\u6570\u3054\u3068\u306b\u5206\u5272\u3057\u307e\u3059\u3002<br \/>\n\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$chunks = $collection-&gt;<strong>chunk(2)<\/strong>;\r\nprint_r($chunks-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u540d\u524d\u30c7\u30fc\u30bf\u3092\uff12\u4ef6\u305a\u3064\u306b\u5206\u5272\u3057\u307e\u3059\u3002\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u306a\u304a\u3001\u914d\u5217\u306e\u4e2d\u8eab\u306e\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\uff10\u301c\uff14\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n    (\r\n        <strong>[0]<\/strong> =&gt; \u9234\u6728\r\n        <strong>[1]<\/strong> =&gt; \u4f50\u85e4\r\n    )\r\n\r\n    [1] =&gt; Array\r\n    (\r\n        <strong>[2]<\/strong> =&gt; \u7530\u4e2d\r\n        <strong>[3]<\/strong> =&gt; \u5c71\u672c\r\n    )\r\n\r\n    [2] =&gt; Array\r\n    (\r\n        <strong>[4]<\/strong> =&gt; \u85e4\u539f\r\n    )\r\n\r\n)<\/pre>\n<h2>split()\u3067\u6307\u5b9a\u6570\u306b\u30c7\u30fc\u30bf\u3092\u5206\u5272\u3059\u308b<\/h2>\n<p><a href=\"#chunk\">chunk()<\/a>\u306e\u5834\u5408\u306f\u30c7\u30fc\u30bf\u4ef6\u6570\u3092\u6307\u5b9a\u3057\u3066\u5206\u5272\u3092\u3057\u307e\u3057\u305f\u304c\u3001<code>split()<\/code>\u3067\u306f\u300c\u4f55\u5206\u5272\u3057\u305f\u3044\u304b\u300d\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$groups = $collection-&gt;<strong>split(3)<\/strong>;\r\nprint_r($groups-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u306f\u30c7\u30fc\u30bf\u3092\uff13\u5206\u5272\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [0] =&gt; \u9234\u6728\r\n            [1] =&gt; \u4f50\u85e4\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            [2] =&gt; \u7530\u4e2d\r\n            [3] =&gt; \u5c71\u672c\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [4] =&gt; \u85e4\u539f\r\n        )\r\n\r\n)\r\n<\/pre>\n<h2>collapse()\u3067\u30c7\u30fc\u30bf\u3092\u5e73\u5766\u5316\u3059\u308b<\/h2>\n<p>\u591a\u91cd\u914d\u5217\u3068\u306a\u3063\u305f\u30c7\u30fc\u30bf\u3092\u5e73\u5766\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['\u9234\u6728', '\u4f50\u85e4'],\r\n    ['\u7530\u4e2d', '\u5c71\u672c'],\r\n    ['\u85e4\u539f']\r\n]);\r\n$collapsed = $collection-&gt;<strong>collapse()<\/strong>;\r\nprint_r($collapsed-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3057\u305f\u3082\u306e\u304c\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u5c71\u672c\r\n    [4] =&gt; \u85e4\u539f\r\n)<\/pre>\n<h2>crossJoin()\u3067\u3001\u3042\u308a\u5f97\u308b\u5168\u3066\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u4f5c\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u6599\u7406\u3068\u98f2\u307f\u7269\u306e\u7d44\u307f\u5408\u308f\u305b\u5168\u3066\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u30e9\u30fc\u30e1\u30f3', '\u30ab\u30ec\u30fc\u30e9\u30a4\u30b9', '\u304a\u597d\u307f\u713c\u304d']<\/strong>);\r\n$new_collection = $collection-&gt;<strong>crossJoin(['\u304a\u8336', '\u30b3\u30fc\u30e9', '\u6c34'])<\/strong>;\r\nprint_r($new_collection-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30e9\u30fc\u30e1\u30f3\r\n            [1] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30e9\u30fc\u30e1\u30f3\r\n            [1] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30e9\u30fc\u30e1\u30f3\r\n            [1] =&gt; \u6c34\r\n        )\r\n\r\n    [3] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30ab\u30ec\u30fc\u30e9\u30a4\u30b9\r\n            [1] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [4] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30ab\u30ec\u30fc\u30e9\u30a4\u30b9\r\n            [1] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [5] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30ab\u30ec\u30fc\u30e9\u30a4\u30b9\r\n            [1] =&gt; \u6c34\r\n        )\r\n\r\n    [6] =&gt; Array\r\n        (\r\n            [0] =&gt; \u304a\u597d\u307f\u713c\u304d\r\n            [1] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [7] =&gt; Array\r\n        (\r\n            [0] =&gt; \u304a\u597d\u307f\u713c\u304d\r\n            [1] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [8] =&gt; Array\r\n        (\r\n            [0] =&gt; \u304a\u597d\u307f\u713c\u304d\r\n            [1] =&gt; \u6c34\r\n        )\r\n\r\n)<\/pre>\n<p>\u3055\u3089\u306b\u3001\u5f15\u6570\u3092\u591a\u91cd\u914d\u5217\u306b\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u591a\u304f\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u30cf\u30f3\u30d0\u30fc\u30ac\u30fc\u306e\u30bb\u30c3\u30c8\u3092\u6ce8\u6587\u3059\u308b\u3068\u304d\u306e\u5168\u7d44\u307f\u5408\u308f\u305b\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc', '\u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc', '\u30d3\u30c3\u30b0\u30de\u30c3\u30af']<\/strong>);\r\n$new_collection = $collection-&gt;crossJoin(\r\n<strong>    ['\u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8', '\u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8'],\r\n    ['\u30b3\u30fc\u30d2\u30fc', '\u30b3\u30fc\u30e9', '\u304a\u8336']<\/strong>\r\n);\r\nprint_r($new_collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7d44\u307f\u5408\u308f\u305b\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30d2\u30fc\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [3] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30d2\u30fc\r\n        )\r\n\r\n    [4] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [5] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30c1\u30fc\u30ba\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [6] =&gt; Array\r\n        (\r\n            [0] =&gt; \u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30d2\u30fc\r\n        )\r\n\r\n    [7] =&gt; Array\r\n        (\r\n            [0] =&gt; \u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [8] =&gt; Array\r\n        (\r\n            [0] =&gt; \u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [9] =&gt; Array\r\n        (\r\n            [0] =&gt; \u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30d2\u30fc\r\n        )\r\n\r\n    [10] =&gt; Array\r\n        (\r\n            [0] =&gt; \u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [11] =&gt; Array\r\n        (\r\n            [0] =&gt; \u3066\u308a\u3084\u304d\u30d0\u30fc\u30ac\u30fc\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [12] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30d3\u30c3\u30b0\u30de\u30c3\u30af\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30d2\u30fc\r\n        )\r\n\r\n    [13] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30d3\u30c3\u30b0\u30de\u30c3\u30af\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [14] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30d3\u30c3\u30b0\u30de\u30c3\u30af\r\n            [1] =&gt; \u30d5\u30e9\u30a4\u30c9\u30dd\u30c6\u30c8\r\n            [2] =&gt; \u304a\u8336\r\n        )\r\n\r\n    [15] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30d3\u30c3\u30b0\u30de\u30c3\u30af\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30d2\u30fc\r\n        )\r\n\r\n    [16] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30d3\u30c3\u30b0\u30de\u30c3\u30af\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u30b3\u30fc\u30e9\r\n        )\r\n\r\n    [17] =&gt; Array\r\n        (\r\n            [0] =&gt; \u30d3\u30c3\u30b0\u30de\u30c3\u30af\r\n            [1] =&gt; \u30c1\u30ad\u30f3\u30ca\u30b2\u30c3\u30c8\r\n            [2] =&gt; \u304a\u8336\r\n        )\r\n\r\n)\r\n\r\n<\/pre>\n<h2>flatMap()\u3067\u5168\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5168\u30c7\u30fc\u30bf\u306e\u6587\u5b57\u6570\u3092\u6570\u3048\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    ['name' =&gt; '\u9234\u6728'],<\/strong>\r\n<strong>    ['todofuken' =&gt; '\u6771\u4eac\u90fd'],<\/strong>\r\n<strong>    ['major' =&gt; '\u7d4c\u55b6\u5b66'],<\/strong>\r\n<strong>]<\/strong>);\r\n$flattened = $collection-&gt;<strong>flatMap(function ($values) {<\/strong>\r\n\r\n<strong>    return array_map('mb_strlen', $values);<\/strong>\r\n\r\n<strong>}<\/strong>);\r\nprint_r($flattened-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30ad\u30fc\u3054\u3068\u306b\u30ab\u30a6\u30f3\u30c8\u3055\u308c\u305f\u6587\u5b57\u6570\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[name]<\/strong> =&gt; 2\r\n    <strong>[todofuken]<\/strong> =&gt; 3\r\n    <strong>[major]<\/strong> =&gt; 3\r\n)\r\n<\/pre>\n<h2>flatten()\u3067\u591a\u6b21\u5143\u914d\u5217\u3092\uff11\u6b21\u5143\u914d\u5217\u306b\u3059\u308b<\/h2>\n<p>\u591a\u6b21\u5143\u914d\u5217\u3092\uff11\u6b21\u5143\u914d\u5217\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'red' =&gt; '\u8d64',\r\n    'others' =&gt; ['\u9752', '\u9ec4\u8272']\r\n]);\r\n$flattened = $collection-&gt;<strong>flatten()<\/strong>;\r\nprint_r($flattened-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u8d64\r\n    [1] =&gt; \u9752\r\n    [2] =&gt; \u9ec4\u8272\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u306f\u4fdd\u6301\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<h2>flip()\u3067\u30ad\u30fc\u3068\u5024\u3092\u5165\u308c\u66ff\u3048\u308b<\/h2>\n<p>\u30ad\u30fc\u3068\u5024\u3092\u5165\u308c\u66ff\u3048\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n<strong>    'key_1' =&gt; 'value_1',\r\n    'key_2' =&gt; 'value_2',\r\n    'key_3' =&gt; 'value_3'<\/strong>\r\n]);\r\n$flipped = $collection-&gt;<strong>flip()<\/strong>;\r\nprint_r($flipped-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n<strong>    [value_1] =&gt; key_1\r\n    [value_2] =&gt; key_2\r\n    [value_3] =&gt; key_3<\/strong>\r\n)\r\n<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<strong>\u5024\u304c\u91cd\u8907\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u6700\u5f8c\u306e\u3082\u306e\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/strong><\/p>\n<pre>$collection = collect([\r\n    'key_1' =&gt; 'value_1',\r\n    'key_2' =&gt; 'value_1',\r\n    <strong>'key_3' =&gt; 'value_1'<\/strong>\r\n]);\r\n$flipped = $collection-&gt;flip();\r\nprint_r($flipped-&gt;toArray());<\/pre>\n<p>\uff08\u5b9f\u884c\u7d50\u679c\uff09<\/p>\n<pre>Array\r\n(\r\n    <strong>[value_1] =&gt; key_3<\/strong>\r\n)<\/pre>\n<h2>groupBy()\u3067\u30ad\u30fc\u3054\u3068\u306b\u30c7\u30fc\u30bf\u3092\u307e\u3068\u3081\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u3054\u3068\u306b\u30c7\u30fc\u30bf\u3092\u5206\u3051\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'age' =&gt; 20<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', <strong>'age' =&gt; 23<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'age' =&gt; 20<\/strong>],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', <strong>'age' =&gt; 25<\/strong>],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', <strong>'age' =&gt; 25<\/strong>],\r\n]);\r\n$grouped = $collection-&gt;<strong>groupBy('age')<\/strong>;\r\nprint_r($grouped-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[20]<\/strong> =&gt; Array\r\n        (\r\n            [0] =&gt; Array\r\n                (\r\n                    [id] =&gt; 1\r\n                    [name] =&gt; \u9234\u6728\r\n                    <strong>[age] =&gt; 20<\/strong>\r\n                )\r\n\r\n            [1] =&gt; Array\r\n                (\r\n                    [id] =&gt; 3\r\n                    [name] =&gt; \u7530\u4e2d\r\n                    <strong>[age] =&gt; 20<\/strong>\r\n                )\r\n\r\n        )\r\n\r\n    <strong>[23]<\/strong> =&gt; Array\r\n        (\r\n            [0] =&gt; Array\r\n                (\r\n                    [id] =&gt; 2\r\n                    [name] =&gt; \u4f50\u85e4\r\n                    <strong>[age] =&gt; 23<\/strong>\r\n                )\r\n\r\n        )\r\n\r\n    <strong>[25]<\/strong> =&gt; Array\r\n        (\r\n            [0] =&gt; Array\r\n                (\r\n                    [id] =&gt; 4\r\n                    [name] =&gt; \u5c71\u672c\r\n                    <strong>[age] =&gt; 25<\/strong>\r\n                )\r\n\r\n            [1] =&gt; Array\r\n                (\r\n                    [id] =&gt; 5\r\n                    [name] =&gt; \u85e4\u539f\r\n                    <strong>[age] =&gt; 25<\/strong>\r\n                )\r\n\r\n        )\r\n\r\n)<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\uff11\u6b21\u5143\u306e\u30ad\u30fc\u304c\u300c\u5e74\u9f62\u300d\u306b\u306a\u308a\u3001\u4e2d\u8eab\u304c\u30bc\u30ed\u304b\u3089\u59cb\u307e\u308b\u914d\u5217\u3068\u3057\u3066\u30c7\u30fc\u30bf\u304c\u632f\u308a\u5206\u3051\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u3001\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b\u30ad\u30fc\u3092\u72ec\u81ea\u306b\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u5f15\u6570\u306b<code>function(){ ... }<\/code>\u3092\u4f7f\u3046\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre>$grouped = $collection-&gt;groupBy(<strong>function($item, $key){<\/strong>\r\n\r\n<strong>    return 'age-'. $item['age']; <\/strong>\/\/ \u4f8b\uff1aage-20\r\n\r\n<strong>})<\/strong>;<\/pre>\n<p>\u307e\u305f\u3001\u5143\u30c7\u30fc\u30bf\u306e\u30ad\u30fc\u3092\u4fdd\u6301\u3057\u305f\u3044\u5834\u5408\u306f\u7b2c\uff13\u5f15\u6570\u306b<code>true<\/code>\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>$grouped = $collection-&gt;groupBy(function($item, $key){\r\n\r\n    return 'age-'. $item['age'];\r\n}, <strong>true<\/strong>);<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [age-20] =&gt; Array\r\n        (\r\n            <strong>[0]<\/strong> =&gt; Array\r\n                (\r\n                    [id] =&gt; 1\r\n                    [name] =&gt; \u9234\u6728\r\n                    [age] =&gt; 20\r\n                )\r\n\r\n            <strong>[2]<\/strong> =&gt; Array\r\n                (\r\n                    [id] =&gt; 3\r\n                    [name] =&gt; \u7530\u4e2d\r\n                    [age] =&gt; 20\r\n                )\r\n\r\n        )\r\n\r\n    [age-23] =&gt; Array\r\n        (\r\n            <strong>[1]<\/strong> =&gt; Array\r\n                (\r\n                    [id] =&gt; 2\r\n                    [name] =&gt; \u4f50\u85e4\r\n                    [age] =&gt; 23\r\n                )\r\n\r\n        )\r\n\r\n    [age-25] =&gt; Array\r\n        (\r\n            <strong>[3]<\/strong> =&gt; Array\r\n                (\r\n                    [id] =&gt; 4\r\n                    [name] =&gt; \u5c71\u672c\r\n                    [age] =&gt; 25\r\n                )\r\n\r\n            <strong>[4]<\/strong> =&gt; Array\r\n                (\r\n                    [id] =&gt; 5\r\n                    [name] =&gt; \u85e4\u539f\r\n                    [age] =&gt; 25\r\n                )\r\n\r\n        )\r\n\r\n)\r\n<\/pre>\n<h2>keyBy()\u3067\u30ad\u30fc\u3054\u3068\u306b\u30c7\u30fc\u30bf\u3092\u307e\u3068\u3081\u308b<\/h2>\n<p><a href=\"#groupBy\">groupBy()<\/a>\u3068\u540c\u69d8\u306b\u30ad\u30fc\u3054\u3068\u306b\u30c7\u30fc\u30bf\u3092\u914d\u5217\u3067\u307e\u3068\u3081\u307e\u3059\u304c\u3001<code>keyBy()<\/code>\u306e\u5834\u5408\u306f\u30ad\u30fc\u3054\u3068\u306b\uff11\u3064\u306e\u30c7\u30fc\u30bf\u3057\u304b\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3064\u307e\u308a\u91cd\u8907\u3059\u308b\u3082\u306e\u306f\u6700\u5f8c\u306e\u30c7\u30fc\u30bf\u306e\u307f\u53d6\u5f97\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'age' =&gt; 20<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', <strong>'age' =&gt; 23<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'age' =&gt; 20<\/strong>],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', <strong>'age' =&gt; 25<\/strong>],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', <strong>'age' =&gt; 25<\/strong>],\r\n]);\r\n$keyed = $collection-&gt;<strong>keyBy('age')<\/strong>;\r\nprint_r($keyed-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u5e74\u9f62\u3054\u3068\u306b\u30c7\u30fc\u30bf\u3092\u307e\u3068\u3081\u307e\u3059\u304c\u53d6\u5f97\u3067\u304d\u308b\u30c7\u30fc\u30bf\u306f\u91cd\u8907\u3057\u305f\u3082\u306e\u3092\u9664\u3044\u305f\uff13\u4ef6\u3060\u3051\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u5168\u3066\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u306f<a href=\"#groupBy\">groupBy()<\/a>\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[20]<\/strong> =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            [name] =&gt; \u7530\u4e2d\r\n            <strong>[age] =&gt; 20<\/strong>\r\n        )\r\n\r\n    <strong>[23]<\/strong> =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            <strong>[age] =&gt; 23<\/strong>\r\n        )\r\n\r\n    <strong>[25]<\/strong> =&gt; Array\r\n        (\r\n            [id] =&gt; 5\r\n            [name] =&gt; \u85e4\u539f\r\n            <strong>[age] =&gt; 25<\/strong>\r\n        )\r\n\r\n)<\/pre>\n<p>\u307e\u305f\u3001<a href=\"#groupBy\">groupBy()<\/a>\u3068\u540c\u3058\u304f\u3001\u5f15\u6570\u306b<code>function(){ ... }<\/code>\u3092\u4f7f\u3063\u3066\u72ec\u81ea\u306e\u30ad\u30fc\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$keyed = $collection-&gt;keyBy(<strong>function($item, $key){<\/strong>\r\n\r\n<strong>    return 'age-'. $item['age']; <\/strong>\/\/ \u4f8b\uff1aage-20\r\n\r\n<strong>}<\/strong>);<\/pre>\n<h2>map()\u3067\u5168\u3066\u306e\u30c7\u30fc\u30bf\u306b\u7279\u5b9a\u306e\u52a0\u5de5\u3092\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u540d\u524d\u30c7\u30fc\u30bf\u306b\u300c\u69d8\u300d\u3092\u3064\u3051\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$new_collection = $collection-&gt;<strong>map(function($item, $key){<\/strong>\r\n\r\n<strong>    return $item .' \u69d8';<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($new_collection-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728 \u69d8\r\n    [1] =&gt; \u4f50\u85e4 \u69d8\r\n    [2] =&gt; \u7530\u4e2d \u69d8\r\n    [3] =&gt; \u5c71\u672c \u69d8\r\n    [4] =&gt; \u85e4\u539f \u69d8\r\n)<\/pre>\n<h2>transform()\u3067\u5168\u3066\u306e\u30c7\u30fc\u30bf\u306b\u7279\u5b9a\u306e\u52a0\u5de5\u3092\u3059\u308b<\/h2>\n<p><a href=\"#map\">map()<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001<code>map()<\/code>\u304c\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u4f5c\u308b\u306e\u306b\u5bfe\u3057\u3066\u3001\u3053\u3061\u3089\u306f\u5143\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$collection-&gt;<strong>transform(function($item, $key){<\/strong>\r\n\r\n<strong>    return $item .' \u69d8';<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728 \u69d8\r\n    [1] =&gt; \u4f50\u85e4 \u69d8\r\n    [2] =&gt; \u7530\u4e2d \u69d8\r\n    [3] =&gt; \u5c71\u672c \u69d8\r\n    [4] =&gt; \u85e4\u539f \u69d8\r\n)\r\n<\/pre>\n<h2>mapInto()\u3067\u5168\u3066\u306e\u8981\u7d20\u3092\u7279\u5b9a\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u65e5\u4ed8\u30c7\u30fc\u30bf\u3092\u3059\u3079\u3066<code>Carbon<\/code>\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u3057\u3066\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['2000-01-01', '2000-02-02', '2000-03-03']);\r\n$date_times = $collection-&gt;<strong>mapInto(Carbon::class)<\/strong>;<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-752\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/collection_mapinto.png\" alt=\"\" width=\"394\" height=\"262\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/collection_mapinto.png 394w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/collection_mapinto-300x199.png 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u3082\u3061\u308d\u3093\u72ec\u81ea\u30af\u30e9\u30b9\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u3066\u3001\u305d\u306e\u5834\u5408\u306f\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u5404\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u304f\u308b\u3088\u3046\u306a\u30af\u30e9\u30b9\u69cb\u6210\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre>class Customer {\r\n\r\n    public function __construct(<strong>string $name<\/strong>)\r\n    {\r\n        $this-&gt;name = $name;\r\n    }\r\n\r\n}<\/pre>\n<h2>mapSpread()\u3067\u5909\u6570\u306b\u683c\u7d0d\u3057\u306a\u304c\u3089\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u591a\u91cd\u914d\u5217\u306b\u306a\u3063\u305f\u30c7\u30fc\u30bf\u3092\uff11\u884c\u305a\u3064\u53d6\u308a\u51fa\u3057\u3066\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d'],\r\n    ['\u5c71\u672c', '\u85e4\u539f', '\u6728\u6751']\r\n]);\r\n$sequence = $collection-&gt;<strong>mapSpread(function ($name_1, $name_2, $name_3) {<\/strong>\r\n\r\n<strong>    return $name_1 .' \uff06 '. $name_2 .' \uff06 '. $name_3;<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($sequence-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; <strong>\u9234\u6728 \uff06 \u4f50\u85e4 \uff06 \u7530\u4e2d<\/strong>\r\n    [1] =&gt; <strong>\u5c71\u672c \uff06 \u85e4\u539f \uff06 \u6728\u6751<\/strong>\r\n)\r\n<\/pre>\n<h2>mapToGroups()\u3067\uff11\u884c\u305a\u3064\u53d6\u5f97\u3057\u306a\u304c\u3089\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u3054\u3068\u306b\u30b0\u30eb\u30fc\u30d7\u3092\u3064\u304f\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<p><a href=\"#groupBy\">groupBy()<\/a>\u3067\u3082\u540c\u3058\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001<code>mapToGroups()<\/code>\u306e\u5834\u5408\u306f\u540c\u6642\u306b\u5404\u30c7\u30fc\u30bf\u306b\u3044\u308d\u3093\u306a\u52a0\u5de5\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 23],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 25],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 25],\r\n]);\r\n$grouped = $collection-&gt;<strong>mapToGroups(function ($item, $key) {<\/strong>\r\n\r\n<strong>    $age = 'age-'. $item['age']; \/\/ \u4f8b\uff1a \"age-20\"<\/strong>\r\n<strong>    $name = $item['name'] .' \u3055\u3093'; \/\/ \u4f8b\uff1a \"\u9234\u6728 \u3055\u3093\"<\/strong>\r\n<strong>    return [$age =&gt; $name];<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($grouped-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [<strong>age-20<\/strong>] =&gt; Array\r\n        (\r\n            [0] =&gt; <strong>\u9234\u6728 \u3055\u3093<\/strong>\r\n            [1] =&gt; <strong>\u7530\u4e2d \u3055\u3093<\/strong>\r\n        )\r\n\r\n    [<strong>age-23<\/strong>] =&gt; Array\r\n        (\r\n            [0] =&gt; <strong>\u4f50\u85e4 \u3055\u3093<\/strong>\r\n        )\r\n\r\n    [<strong>age-25<\/strong>] =&gt; Array\r\n        (\r\n            [0] =&gt; <strong>\u5c71\u672c \u3055\u3093<\/strong>\r\n            [1] =&gt; <strong>\u85e4\u539f \u3055\u3093<\/strong>\r\n        )\r\n\r\n)<\/pre>\n<p><code>return<\/code>\u3059\u308b\u306e\u304c\u9023\u60f3\u914d\u5217\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>mapWithKeys()\u3067\u9023\u60f3\u914d\u5217\u3092\u3064\u304f\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u3042\u308b\u30c7\u30fc\u30bf\u304b\u3089\u7279\u5b9a\u306e\u9023\u60f3\u914d\u5217\u3092\u4f5c\u6210\u3059\u308b\u5834\u5408\u3067\u3059\u3002<a href=\"#mapToGroups\">mapToGroups()<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u30ad\u30fc\u304c\u91cd\u8907\u3059\u308b\u5834\u5408\u306f\u4e0a\u66f8\u304d\u3055\u308c\u307e\u3059\u3002\uff08\u3064\u307e\u308a\uff11\u3064\u306e\u30ad\u30fc\u306b\u306f\uff11\u3064\u306e\u5024\u3057\u304b\u4fdd\u6301\u3067\u304d\u306a\u3044\uff09<\/p>\n<p>\u3067\u306f\u3001\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect(<strong>[\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 23],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 25],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 25],\r\n]<\/strong>);\r\n$grouped = $collection-&gt;<strong>mapWithKeys(function ($item) {<\/strong>\r\n\r\n<strong>    $age = 'age-'. $item['age'];<\/strong>\r\n<strong>    $name = $item['name'] .' \u3055\u3093';<\/strong>\r\n<strong>    return [$age =&gt; $name];<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($grouped-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002\uff0820\u6b73\u306825\u6b73\u304c\u91cd\u8907\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u5168\u90e8\u3067\uff13\u4ef6\u3060\u3051\u3067\u3059\uff09<\/p>\n<pre>Array\r\n(\r\n    [age-20] =&gt; \u7530\u4e2d \u3055\u3093\r\n    [age-23] =&gt; \u4f50\u85e4 \u3055\u3093\r\n    [age-25] =&gt; \u85e4\u539f \u3055\u3093\r\n)<\/pre>\n<h2>pad()\u3067\u30c7\u30fc\u30bf\u6570\u3092\u63c3\u3048\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5024\u304c\uff13\u3064\u3042\u308b<code>Collection<\/code>\u3092\uff15\u3064\u306b\u63c3\u3048\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d']<\/strong>);\r\n$new_collection = $collection-&gt;<strong>pad(5, '\uff08\u6b20\u5e2d\uff09')<\/strong>;\r\nprint_r($new_collection-&gt;toArray());<\/pre>\n<p>\u4e0a\u306e\u4f8b\u3067\u306f\u3001\u30c7\u30fc\u30bf\u6570\u306f\uff13\u3064\u306a\u306e\u306b\u5bfe\u3057\u3066<code>pad()<\/code>\u3067\u306f\uff15\u3064\u306b\u306a\u308b\u3088\u3046\u6307\u5b9a\u3057\u3066\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u8db3\u308a\u306a\u3044\u6587\u306e\u30c7\u30fc\u30bf\u306f\u300c\uff08\u6b20\u5e2d\uff09\u300d\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \uff08\u6b20\u5e2d\uff09\r\n    [4] =&gt; \uff08\u6b20\u5e2d\uff09\r\n)<\/pre>\n<h2>partition()\u3067\uff12\u30b0\u30eb\u30fc\u30d7\u306b\u5206\u3051\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u30c6\u30b9\u30c8\u306780\u70b9\u4ee5\u4e0a\u53d6\u3063\u305f\u70b9\u6570\u3068\u3001\u305d\u3046\u3067\u306a\u3044\u70b9\u6570\u3092\u5206\u3051\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[80, 73, 60, 98, 22]<\/strong>);\r\nlist($pass, $fail) = $collection-&gt;<strong>partition(function($score){<\/strong>\r\n\r\n<strong>    return ($score &gt;= 80);<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($pass-&gt;toArray());\r\nprint_r($fail-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[0]<\/strong> =&gt; 80\r\n    <strong>[3]<\/strong> =&gt; 98\r\n)\r\nArray\r\n(\r\n    <strong>[1]<\/strong> =&gt; 73\r\n    <strong>[2]<\/strong> =&gt; 60\r\n    <strong>[4]<\/strong> =&gt; 22\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>pipe()\u3067Collection\u3092function()\u3078\u9001\u308a\u8fd4\u308a\u5024\u3092\u53d7\u3051\u53d6\u308b<\/h2>\n<pre>$collection = collect(['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 20]);\r\n$piped = $collection-&gt;<strong>pipe(function($collection) {<\/strong>\r\n\r\n<strong>    return $collection-&gt;get('age');<\/strong>\r\n\r\n<strong>})<\/strong>;\r\nprint_r($piped);<\/pre>\n<h2>skip()\u3067\u6307\u5b9a\u306e\u6570\u3060\u3051\u98db\u3070\u3057\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u3042\u3001\u3044\u3001\u3046\u3001\u3048\u3001\u304a<\/strong>\u300d\u304b\u3089\u300c<strong>\u3042\u3001\u3044\u3001\u3046<\/strong>\u300d\u3092\u98db\u3070\u3057\u3066\u300c<strong>\u3048\u3001\u304a<\/strong>\u300d\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(['\u3042', '\u3044', '\u3046', '\u3048', '\u304a'])-&gt;<strong>skip(3)<\/strong>; \/\/ 3\u3064\u98db\u3070\u3057\u305f\u30c7\u30fc\u30bf\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u203b\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u5185\u90e8\u306b\u306f<a href=\"#slice\">slice()<\/a>\u304c\u547c\u3070\u308c\u3066\u3044\u307e\u3059\u304c\u3001<code>slice()<\/code>\u306e\u3088\u3046\u306b\u7b2c\uff12\u5f15\u6570\u306f\u53d7\u3051\u4ed8\u3051\u307e\u305b\u3093\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 6.x \u4ee5\u964d<\/em><\/p>\n<h2>slice()\u3067\u30c7\u30fc\u30bf\u3092\u629c\u304d\u51fa\u3059<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\uff13\u756a\u3081\u4ee5\u964d\u306e\u30c7\u30fc\u30bf\u3060\u3051\u629c\u304d\u51fa\u3059\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$slice = $collection-&gt;<strong>slice(2)<\/strong>; \/\/ 0\u304b\u3089\u59cb\u307e\u308b\u6570\u5b57\u3002\u3053\u3053\u4ee5\u964d\u304c\u6b8b\u308b\r\nprint_r($slice-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u5c71\u672c\r\n    [4] =&gt; \u85e4\u539f\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u7b2c\uff12\u5f15\u6570\u3067\u4ef6\u6570\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$slice = $collection-&gt;<strong>slice(2, 2)<\/strong>;<\/pre>\n<p>\u7d50\u679c\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [2] =&gt; \u7530\u4e2d\r\n    [3] =&gt; \u5c71\u672c\r\n)<\/pre>\n<h2>splice()\u3067\u30c7\u30fc\u30bf\u3092\u629c\u304d\u51fa\u3059<\/h2>\n<p><a href=\"#slice\">slice()<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001<code>splice()<\/code>\u306f\u5143\u30c7\u30fc\u30bf\u3092\u8a72\u5f53\u3059\u308b\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u3001\u305d\u306e\u524a\u9664\u3057\u305f\u30c7\u30fc\u30bf\u3092\u5143\u306b\u65b0\u3057\u3044<code>Collection<\/code>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$chunk = $collection-&gt;<strong>splice(2)<\/strong>; \/\/ 0\u304b\u3089\u59cb\u307e\u308b\u6570\u5b57\u3002\u3053\u3053\u4ee5\u964d\u304c\u524a\u9664\u3055\u308c\u308b\r\nprint_r($collection-&gt;toArray());\r\nprint_r($chunk-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\uff08\u5143\u30c7\u30fc\u30bf\uff09\r\n(\r\n    [0] =&gt; \u9234\u6728\r\n    [1] =&gt; \u4f50\u85e4\r\n)\r\nArray\uff08\u65b0\u3057\u3044\u30c7\u30fc\u30bf\uff09\r\n(\r\n    [0] =&gt; \u7530\u4e2d\r\n    [1] =&gt; \u5c71\u672c\r\n    [2] =&gt; \u85e4\u539f\r\n)\r\n<\/pre>\n<p>\u307e\u305f\u3001slice()\u3068\u540c\u69d8\u306b\u7b2c\uff12\u5f15\u6570\u3067\u4ef6\u6570\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$chunk = $collection-&gt;<strong>splice(2, 1)<\/strong>;<\/pre>\n<h2>replace()\u3067\u30c7\u30fc\u30bf\u3092\u5165\u308c\u66ff\u3048\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u3059\u3067\u306b\u5b58\u5728\u3057\u3066\u3044\u308b\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u4e00\u90e8\u3092\u5165\u308c\u66ff\u3048\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$replaced = collect(['\u592a\u90ce', '\u6b21\u90ce', '\u4e09\u90ce'])-&gt;<strong>replace([<\/strong>\r\n<strong>    1 =&gt; '\u56db\u90ce', \/\/ \u6b21\u90ce \u2192 \u56db\u90ce,<\/strong>\r\n<strong>    3 =&gt; '\u4e94\u90ce', \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b93\u306b\u8ffd\u52a0<\/strong>\r\n<strong>])<\/strong>;\r\nprint_r($replaced-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u306f\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7<code>1<\/code>\u306f\u300c\u6b21\u90ce\u300d\u306a\u306e\u3067\u300c\u56db\u90ce\u300d\u3068\u5165\u308c\u66ff\u308f\u308a\u307e\u3059\u304c\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7<code>3<\/code>\u306f\u5b58\u5728\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u305d\u306e\u307e\u307e\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u592a\u90ce\r\n    <strong>[1] =&gt; \u56db\u90ce \/\/ \u5165\u308c\u66ff\u308f\u3063\u305f<\/strong>\r\n    [2] =&gt; \u4e09\u90ce\r\n    <strong>[3] =&gt; \u4e94\u90ce \/\/ \u8ffd\u52a0\u3055\u308c\u305f<\/strong>\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.8.28 \u4ee5\u964d<\/em><\/p>\n<h2>replaceRecursive()\u3067\u968e\u5c64\u304c\u6df1\u3044\u30c7\u30fc\u30bf\u3092\u5165\u308c\u66ff\u3048\u308b<\/h2>\n<p><a href=\"#replace\">replace()<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3053\u3061\u3089\u306f\u3001\u6df1\u3044\u968e\u5c64\u306e\u30c7\u30fc\u30bf\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$replaced = collect([\r\n    '\u592a\u90ce',\r\n    '\u6b21\u90ce',\r\n    ['id' =&gt; 55, 'name' =&gt; '\u4e09\u90ce']\r\n])-&gt;<strong>replaceRecursive([<\/strong>\r\n<strong>    1 =&gt; '\u56db\u90ce', <\/strong>\/\/ \u6b21\u90ce \u2192 \u56db\u90ce,\r\n<strong>    2 =&gt; [<\/strong>\r\n<strong>        'id' =&gt; 99 <\/strong>\/\/ 55 \u2192 99\r\n<strong>    ],<\/strong>\r\n<strong>])<\/strong>;\r\nprint_r($replaced-&gt;toArray());<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7<code>1<\/code>\u306e\u300c\u6b21\u90ce\u300d\u306f\u300c\u56db\u90ce\u300d\u306b\u7f6e\u304d\u63db\u308f\u308a\u3001\u3055\u3089\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7<code>2<\/code>\u306e<code>id<\/code>\u306e\u5024\u304c<code>55<\/code>\u304b\u3089<code>99<\/code>\u3078\u5909\u66f4\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; \u592a\u90ce\r\n    <strong>[1] =&gt; \u56db\u90ce \/\/ \u5165\u308c\u66ff\u308f\u3063\u305f<\/strong>\r\n    [2] =&gt; Array\r\n    (\r\n        <strong>[id] =&gt; 99 \/\/ \u5165\u308c\u66ff\u308f\u3063\u305f<\/strong>\r\n        [name] =&gt; \u4e09\u90ce\r\n    )\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.8.28 \u4ee5\u964d<\/em><\/p>\n<h1>\u30c7\u30fc\u30bf\u3092\u4e26\u3079\u66ff\u3048\u308b<\/h1>\n<h2>sort()\u3067\u6607\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p>\u5c0f\u3055\u3044\u5024\u304b\u3089\u9806\u756a\u306b\u4e26\u3079\u66ff\u3048\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[80, 15, 93, 63, 25]<\/strong>);\r\n$sorted = $collection-&gt;<strong>sort()<\/strong>;\r\nprint_r($sorted-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[1]<\/strong> =&gt; 15\r\n    <strong>[4]<\/strong> =&gt; 25\r\n    <strong>[3]<\/strong> =&gt; 63\r\n    <strong>[0]<\/strong> =&gt; 80\r\n    <strong>[2]<\/strong> =&gt; 93\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>sortDesc()\u3067\u964d\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p><a href=\"#sort\">sort()<\/a>\u306e\u65b9\u5411\u304c\u9006\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<br \/>\n\u8a73\u3057\u304f\u306f\u524d\u9805\u76ee\u306e<code>sort()<\/code>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 7.x \u4ee5\u964d<\/em><\/p>\n<h2>sortBy()\u3067\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u6607\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u306e\u82e5\u3044\u9806\u306b\u4f1a\u54e1\u30c7\u30fc\u30bf\u3092\u4e26\u3079\u66ff\u3048\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 16],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 30],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 27],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 35],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 23],\r\n]);\r\n$sorted = $collection-&gt;<strong>sortBy('age')<\/strong>;\r\nprint_r($sorted-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [id] =&gt; 1\r\n            [name] =&gt; \u9234\u6728\r\n            <strong>[age] =&gt; 16<\/strong>\r\n        )\r\n\r\n    [4] =&gt; Array\r\n        (\r\n            [id] =&gt; 5\r\n            [name] =&gt; \u85e4\u539f\r\n            <strong>[age] =&gt; 23<\/strong>\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            [name] =&gt; \u7530\u4e2d\r\n            <strong>[age] =&gt; 27<\/strong>\r\n        )\r\n\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            <strong>[age] =&gt; 30<\/strong>\r\n        )\r\n\r\n    [3] =&gt; Array\r\n        (\r\n            [id] =&gt; 4\r\n            [name] =&gt; \u5c71\u672c\r\n            <strong>[age] =&gt; 35<\/strong>\r\n        )\r\n\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001<code>sortBy()<\/code>\u306e\u5f15\u6570\u306b\u306f<code>function(){ ... }<\/code>\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u8da3\u5473\u304c\u5c11\u306a\u3044\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'hobbies' =&gt; ['\u30d4\u30a2\u30ce', '\u8aad\u66f8']<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', <strong>'hobbies' =&gt; ['\u767b\u5c71']<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'hobbies' =&gt; ['\u30b4\u30eb\u30d5', '\u6599\u7406', '\u30e8\u30ac']<\/strong>]\r\n]);\r\n$sorted = $collection-&gt;sortBy(<strong>function($item, $key){<\/strong>\r\n\r\n<strong>    return count($item['hobbies']);<\/strong>\r\n\r\n<strong>}<\/strong>);\r\nprint_r($sorted-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u3067\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            <strong>[hobbies] =&gt; Array\r\n                (\r\n                    [0] =&gt; \u767b\u5c71\r\n                )<\/strong>\r\n\r\n        )\r\n\r\n    [0] =&gt; Array\r\n        (\r\n            [id] =&gt; 1\r\n            [name] =&gt; \u9234\u6728\r\n            <strong>[hobbies] =&gt; Array\r\n                (\r\n                    [0] =&gt; \u30d4\u30a2\u30ce\r\n                    [1] =&gt; \u8aad\u66f8\r\n                )<\/strong>\r\n\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            [name] =&gt; \u7530\u4e2d\r\n            <strong>[hobbies] =&gt; Array\r\n                (\r\n                    [0] =&gt; \u30b4\u30eb\u30d5\r\n                    [1] =&gt; \u6599\u7406\r\n                    [2] =&gt; \u30e8\u30ac\r\n                )<\/strong>\r\n\r\n        )\r\n\r\n)\r\n<\/pre>\n<h2>sortByDesc()\u3067\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u964d\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p><a href=\"#sortBy\">sortBy()<\/a>\u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<h2>sortKeys()\u3067\u30ad\u30fc\u306e\u6607\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p>\u30ad\u30fc\u3092\u4f7f\u3063\u3066\u6607\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    <strong>'ccc'<\/strong> =&gt; 3,\r\n    <strong>'aaa'<\/strong> =&gt; 1,\r\n    <strong>'eee'<\/strong> =&gt; 5,\r\n    <strong>'ddd'<\/strong> =&gt; 4,\r\n    <strong>'bbb'<\/strong> =&gt; 2\r\n]);\r\n$sorted = $collection-&gt;<strong>sortKeys()<\/strong>;\r\nprint_r($sorted-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[aaa]<\/strong> =&gt; 1\r\n    <strong>[bbb]<\/strong> =&gt; 2\r\n    <strong>[ccc]<\/strong> =&gt; 3\r\n    <strong>[ddd]<\/strong> =&gt; 4\r\n    <strong>[eee]<\/strong> =&gt; 5\r\n)\r\n<\/pre>\n<h2>sortKeysDesc()\u3067\u30ad\u30fc\u306e\u964d\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p><a href=\"#sortKeys\">sortKeys()<\/a>\u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<h2>reverse()\u3067\u4e26\u3073\u9806\u3092\u53cd\u8ee2\u3055\u305b\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u3092\u9006\u9806\u306b\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$reversed = $collection-&gt;<strong>reverse()<\/strong>;\r\nprint_r($reversed-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    <strong>[4]<\/strong> =&gt; \u85e4\u539f\r\n    <strong>[3]<\/strong> =&gt; \u5c71\u672c\r\n    <strong>[2]<\/strong> =&gt; \u7530\u4e2d\r\n    <strong>[1]<\/strong> =&gt; \u4f50\u85e4\r\n    <strong>[0]<\/strong> =&gt; \u9234\u6728\r\n)\r\n<\/pre>\n<p>\u203b\u9806\u756a\u306f\u5909\u308f\u308a\u307e\u3057\u305f\u304c\u3001\u30ad\u30fc\u306f\u4fdd\u6301\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>shuffle()\u3067\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3079\u66ff\u3048\u308b<\/h2>\n<p>\u4e2d\u8eab\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3079\u66ff\u3048\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']<\/strong>);\r\n$shuffled = $collection-&gt;<strong>shuffle()<\/strong>;\r\nprint_r($shuffled-&gt;toArray());<\/pre>\n<pre>\uff08\u30e9\u30f3\u30c0\u30e0\u306b\u5185\u5bb9\u306f\u5909\u308f\u308a\u307e\u3059\uff09\r\nArray\r\n(\r\n    <strong>[0]<\/strong> =&gt; \u85e4\u539f\r\n    <strong>[1]<\/strong> =&gt; \u7530\u4e2d\r\n    <strong>[2]<\/strong> =&gt; \u4f50\u85e4\r\n    <strong>[3]<\/strong> =&gt; \u5c71\u672c\r\n    <strong>[4]<\/strong> =&gt; \u9234\u6728\r\n)<\/pre>\n<p>\u203b\u30ad\u30fc\u304c\u4fdd\u6301\u3055\u308c\u306a\u3044\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u30c7\u30fc\u30bf\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h1>\n<h2>has()\u3067\u7279\u5b9a\u306e\u30ad\u30fc\u304c\u5b58\u5728\u3059\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u30c7\u30fc\u30bf\uff08age\uff09\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'id' =&gt; 1, \r\n    'name' =&gt; '\u9234\u6728', \r\n    'age' =&gt; 20\r\n]);\r\n\r\nif($collection-&gt;<strong>has('age')<\/strong>) {\r\n\r\n    echo '\u5e74\u9f62\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002';\r\n\r\n}<\/pre>\n<p>\u203b\u6ce8\u610f\u304c\u5fc5\u8981\u306a\u306e\u306f\u3001\u3082\u3057\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u306e\u4e2d\u8eab\u304c<code>null<\/code>\u3084\u7a7a\u767d\u3067\u3082\u3001\u3053\u306e\u4f8b\u3067\u306f<code>true<\/code>\u3068\u306a\u308b\u3053\u3068\u3067\u3059\u3002\u3064\u307e\u308a\u3001\u5358\u7d14\u306b\u30ad\u30fc\u304c\u5b58\u5728\u3057\u3066\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u308b\u3093\u3067\u3059\u306d\u3002<\/p>\n<h2>contains()\u3067\u7279\u5b9a\u306e\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p>\u6307\u5b9a\u3057\u305f\u5024\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = <strong>collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d'])<\/strong>;\r\n\r\nif($collection-&gt;<strong>contains('\u9234\u6728')<\/strong>) {\r\n\r\n    echo '\u9234\u6728\u3055\u3093\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002';\r\n\r\n}<\/pre>\n<p>\u307e\u305f\u3001\u30ad\u30fc\u304c\u5165\u3063\u305f<code>Collection<\/code>\u3067\u3082\u540c\u69d8\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre>$collection = <strong>collect([<\/strong>\r\n<strong>    'id' =&gt; 1,<\/strong>\r\n<strong>    'name' =&gt; '\u9234\u6728',<\/strong>\r\n<strong>    'age' =&gt; 25<\/strong>\r\n<strong>])<\/strong>;\r\n\r\nif($collection-&gt;<strong>contains('\u9234\u6728')<\/strong>) {\r\n\r\n    echo '\u9234\u6728\u3055\u3093\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002';\r\n\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001\u591a\u91cd\u69cb\u9020\u306e\u5834\u5408\u3001\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, <strong>'name' =&gt; '\u9234\u6728'<\/strong>, 'age' =&gt; 20],\r\n    ['id' =&gt; 2, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 22],\r\n    ['id' =&gt; 3, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 30]\r\n]);\r\n\r\nif($collection-&gt;<strong>contains('name', '\u9234\u6728')<\/strong>) {\r\n\r\n    echo '\u300cname\u300d\u306b\u9234\u6728\u3055\u3093\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002';\r\n\r\n}<\/pre>\n<p>\u6700\u5f8c\u306b\u3001<code>function(){ ... }<\/code>\u3092\u4f7f\u3063\u305f\u65b9\u6cd5\u3082\u7d39\u4ecb\u3057\u307e\u3057\u3087\u3046\u3002<code>true<\/code>\u306b\u306a\u308b\u6761\u4ef6\u5f0f\u3092<code>return<\/code>\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, <strong>'name' =&gt; '\u9234\u6728'<\/strong>, 'age' =&gt; 20],\r\n    ['id' =&gt; 2, <strong>'name' =&gt; '\u4f50\u85e4'<\/strong>, 'age' =&gt; 22],\r\n    ['id' =&gt; 3, <strong>'name' =&gt; '\u7530\u4e2d'<\/strong>, 'age' =&gt; 30]\r\n]);\r\n$result = $collection-&gt;<strong>contains(function($values, $key){<\/strong>\r\n\r\n<strong>    return ($values['name'] == '\u9234\u6728');<\/strong>\r\n\r\n<strong>})<\/strong>;\r\n\r\nif($result) {\r\n\r\n    echo '\u9234\u6728\u3055\u3093\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002';\r\n\r\n}<\/pre>\n<h2>some()\u3067\u7279\u5b9a\u306e\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p><a href=\"#contains\">contains()<\/a>\u306e\u30a8\u30a4\u30ea\u30a2\u30b9\u3001\u3064\u307e\u308a\u540c\u3058\u3082\u306e\u3067\u3059\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.7.16 \u4ee5\u964d<\/em><\/p>\n<h2>containsStrict()\u3067\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p>\u57fa\u672c\u7684\u306b\u306f<a href=\"#contains\">contains()<\/a>\u3068\u540c\u3058\u3067\u3059\u304c\u3001\u6bd4\u8f03\u306e\u4ed5\u65b9\u304c\u3088\u308a\u53b3\u3057\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'age' =&gt; 20<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', <strong>'age' =&gt; 22<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'age' =&gt; 30<\/strong>]\r\n]);\r\n\r\nif($collection-&gt;<strong>containsStrict('age', '20')<\/strong>) {\r\n\r\n    \/\/ \u3053\u306e\u6761\u4ef6\u3067\u306f\u300ctrue\u300d\u306b\u306a\u3089\u306a\u3044\r\n\r\n} else if($collection-&gt;<strong>containsStrict('age', 20)<\/strong>) {\r\n\r\n    \/\/ \u3053\u306e\u6761\u4ef6\u3067\u306f\u300ctrue\u300d\u306b\u306a\u308b\r\n\r\n}<\/pre>\n<p>\u4e0a\u306e\u4f8b\u3067\u3059\u3068\u3001\u3072\u3068\u3064\u76ee\u306e<code>containsStrict()<\/code>\u306f<code>false<\/code>\u306b\u306a\u308a\u307e\u3059\u3002\u306a\u305c\u306a\u3089\u3001\u6307\u5b9a\u3055\u308c\u305f\u5024\u304c<code>'20'<\/code>\u3068\u6587\u5b57\u5217\u3068\u3057\u3066\u6bd4\u8f03\u3055\u308c\u3066\u3044\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001<\/p>\n<pre>if($a <strong>===<\/strong> $b) {}<\/pre>\n<p>\u304c\u6210\u308a\u7acb\u3064\u95a2\u4fc2\u3067\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081<code>Boolean<\/code>\u3068\u6570\u5b57\u306e\u6bd4\u8f03\u306a\u3069\u3092\u6ce8\u610f\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>every()\u3067\u5168\u3066\u306e\u8981\u7d20\u304c\u6761\u4ef6\u3092\u30af\u30ea\u30a2\u3057\u3066\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u5168\u54e1\u304c\u30c6\u30b9\u30c8\u306780\u70b9\u4ee5\u4e0a\u3068\u3063\u3066\u308b\u304b\u3069\u3046\u304b<\/strong>\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[80, 100, 95, 82]<\/strong>);\r\n<strong>$result<\/strong> = $collection-&gt;<strong>every(function($value, $key){<\/strong>\r\n\r\n<strong>    return ($value &gt;= 80);<\/strong>\r\n\r\n<strong>})<\/strong>;\r\n\r\nif(<strong>$result<\/strong>) {\r\n\r\n    echo '\u5168\u54e1\u304c80\u70b9\u4ee5\u4e0a\u53d6\u3063\u3066\u3044\u307e\u3059';\r\n\r\n}<\/pre>\n<p>\u3064\u307e\u308a\u3001<code>function(){ ... }<\/code>\u5185\u306e\u6761\u4ef6\u5f0f\u3067\u5168\u3066\u304c<code>true<\/code>\u306b\u306a\u308c\u3070\u3001<code>$result<\/code>\u306f<code>true<\/code>\u3002\u9006\u306b\uff11\u3064\u3067\u3082\u6761\u4ef6\u5f0f\u3092\u6e80\u305f\u3055\u306a\u3044\u30c7\u30fc\u30bf\u304c\u3042\u308b\u5834\u5408\u306f<code>false<\/code>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>isEmpty()\u3067\u4e2d\u8eab\u304c\u7a7a\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p>\u4e2d\u8eab\u304c\u7a7a\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([]);\r\n\r\nif(<strong>$collection-&gt;isEmpty()<\/strong>) {\r\n\r\n    echo '\u4e2d\u8eab\u306f\u7a7a\u3067\u3059\u3002';\r\n\r\n}<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u914d\u5217\u306e<code>null<\/code>\u306e\u5834\u5408\u306f\u3001<code>false<\/code>\uff08\u3064\u307e\u308a\u3001\u7a7a\u3067\u306f\u306a\u3044\uff09\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[null]<\/strong>);\r\n$collection-&gt;<strong>isEmpty()<\/strong>; \/\/ false\uff1a\u7a7a\u3067\u306f\u306a\u3044\u3068\u5224\u65ad\u3055\u308c\u308b<\/pre>\n<p>\u305f\u3060\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4e2d\u8eab\u81ea\u4f53\u304c<code>null<\/code>\u306e\u5834\u5408\u306f\u7a7a\u767d\u3068\u307f\u306a\u3055\u308c\u3066<code>true<\/code>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>null<\/strong>);\r\n$collection-&gt;<strong>isEmpty()<\/strong>; \/\/ true\uff1a\u7a7a\u3067\u3059<\/pre>\n<h2>isNotEmpty()\u3067\u4e2d\u8eab\u304c\u7a7a\u3067\u306f\u306a\u3044\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p><a href=\"#isEmpty\">isEmpty()<\/a>\u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>['xxx']<\/strong>);\r\n\r\nif($collection-&gt;<strong>isNotEmpty()<\/strong>) {\r\n\r\n    echo '\u4e2d\u8eab\u306f\u7a7a\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002';\r\n\r\n}<\/pre>\n<h1>\u30c7\u30fc\u30bf\u306e\u4e2d\u8eab\u3092\u8868\u793a\u3059\u308b<\/h1>\n<h2>dd()\u3067\u30c7\u30fc\u30bf\u306e\u4e2d\u8eab\u3092\u8868\u793a\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u306e\u4e2d\u8eab\u3092\u8868\u793a\u3057\u3001<strong>\u305d\u306e\u5834\u3067\u51e6\u7406\u3092\u7d42\u4e86\u3055\u305b\u307e\u3059\u3002<\/strong><\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$collection-&gt;<strong>dd()<\/strong>;\r\n\r\necho '\u3053\u3053\u306f\u5b9f\u884c\u3055\u308c\u307e\u305b\u3093';<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-736\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/laravel_collection_dd.png\" alt=\"\" width=\"166\" height=\"188\" \/><\/p>\n<h2>dump()\u3067\u30c7\u30fc\u30bf\u306e\u4e2d\u8eab\u3092\u8868\u793a\u3059\u308b<\/h2>\n<p><a href=\"#dd\">dd()<\/a>\u3068\u540c\u3058\u304f\u4e2d\u8eab\u3092\u8868\u793a\u3057\u3066\u304f\u308c\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u9014\u4e2d\u3067\u51e6\u7406\u304c\u7d42\u4e86\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$collection-&gt;<strong>dump()<\/strong>;\r\n\r\n<strong>echo '\u3053\u3053\u306f\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002';<\/strong><\/pre>\n<h1>\u6761\u4ef6\u3067\u5206\u5c90\u3055\u305b\u308b<\/h1>\n<h2>when()\u3067\u6761\u4ef6\u5206\u5c90\u3055\u305b\u308b<\/h2>\n<p>\u3042\u308b\u6761\u4ef6\u304c<code>true<\/code>\u306e\u5834\u5408\u306b\u5b9f\u884c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre>$boolean = <strong>true<\/strong>;\r\n$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c']);\r\n$collection-&gt;<strong>when($boolean, function($collection){<\/strong>\r\n\r\n    \/\/ \u3053\u306e\u4f8b\u3067\u306f\u5b9f\u884c\u3055\u308c\u307e\u3059\r\n\r\n<strong>})<\/strong>;<\/pre>\n<h2>whenEmpty()\u3067\u30c7\u30fc\u30bf\u304c\u7a7a\u306e\u5834\u5408\u3060\u3051\u5b9f\u884c\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>$collection<\/code>\u304c\u7a7a\u306e\u5834\u5408\u306b\u3060\u3051\u300c<strong>\u56db\u90ce<\/strong>\u300d\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(); \/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304c\u7a7a\r\n$collection-&gt;<strong>whenEmpty(function($c){<\/strong>\r\n\r\n<strong>    $c-&gt;push('\u56db\u90ce');<\/strong> \/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304c\u7a7a\u306a\u306e\u3067\u5b9f\u884c\u3055\u308c\u308b\r\n\r\n<strong>})<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u9006\u306b\u6b21\u306e\u5834\u5408\u306f\u300c<strong>\u56db\u90ce<\/strong>\u300d\u304c\u8ffd\u52a0\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre>$collection = collect(<strong>['\u592a\u90ce', '\u6b21\u90ce', '\u4e09\u90ce']<\/strong>); \/\/ \u7a7a\u3067\u306f\u306a\u3044\r\n$collection-&gt;<strong>whenEmpty(function($c){<\/strong>\r\n\r\n<strong>    $c-&gt;push('\u56db\u90ce'); <\/strong>\/\/ \u5b9f\u884c\u3055\u308c\u306a\u3044\r\n\r\n<strong>})<\/strong>;<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.7.13 \u4ee5\u964d<\/em><\/p>\n<h2>whenNotEmpty()\u3067\u30c7\u30fc\u30bf\u304c\u7a7a\u3067\u306f\u306a\u3044\u5834\u5408\u3060\u3051\u5b9f\u884c\u3059\u308b<\/h2>\n<p><a href=\"#whenEmpty\">whenEmpty()<\/a>\u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.7.13 \u4ee5\u964d<\/em><\/p>\n<h2>unless()\u3067\u6761\u4ef6\u5206\u5c90\u3055\u305b\u308b<\/h2>\n<p>\u3042\u308b\u6761\u4ef6\u304c<code>false<\/code>\u306e\u5834\u5408\u306b\u5b9f\u884c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre>$boolean = <strong>false<\/strong>;\r\n$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c']);\r\n$collection-&gt;<strong>unless($boolean, function($collection){<\/strong>\r\n\r\n    \/\/ \u3053\u306e\u4f8b\u3067\u306f\u5b9f\u884c\u3055\u308c\u307e\u3059\r\n\r\n<strong>})<\/strong>;<\/pre>\n<p>\u91cd\u8981\u306a\u306e\u306f<code>false<\/code>\u306e\u5834\u5408\u306b\u5b9f\u884c\u3055\u308c\u308b\u70b9\u3067\u3059\u3002\u3082\u3057<code>true<\/code>\u306e\u5834\u5408\u306b\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f<a href=\"#when\">when()<\/a>\u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>unlessEmpty()\u3067\u30c7\u30fc\u30bf\u304c\u7a7a\u3067\u306f\u306a\u3044\u5834\u5408\u3060\u3051\u5b9f\u884c\u3059\u308b<\/h2>\n<p><a href=\"#whenEmpty\">whenEmpty()<\/a>\u3068\u306f\u9006\u306b<code>$collection<\/code>\u304c\u7a7a\u3067\u306f\u306a\u3044\u5834\u5408\u3060\u3051\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u592a\u90ce', '\u6b21\u90ce', '\u4e09\u90ce']);\r\n$collection-&gt;<strong>unlessEmpty(function($c){<\/strong>\r\n\r\n<strong>    $c-&gt;push('\u56db\u90ce'); <\/strong>\/\/ \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304c\u7a7a\u3067\u306f\u306a\u3044\u306e\u3067\u5b9f\u884c\u3055\u308c\u308b\r\n\r\n<strong>})<\/strong>;\r\nprint_r($collection-&gt;toArray());<\/pre>\n<p>\u9006\u306b\u6b21\u306e\u5834\u5408\u306f\u300c<strong>\u56db\u90ce<\/strong>\u300d\u304c\u8ffd\u52a0\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre>$collection = collect(); \/\/ \u7a7a\r\n$collection-&gt;<strong>whenEmpty(function($c){<\/strong>\r\n\r\n<strong>    $c-&gt;push('\u56db\u90ce'); <\/strong>\/\/ \u5b9f\u884c\u3055\u308c\u306a\u3044\r\n\r\n<strong>})<\/strong>;<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.7.13 \u4ee5\u964d<\/em><\/p>\n<h2>unlessNotEmpty()\u3067\u30c7\u30fc\u30bf\u304c\u7a7a\u306e\u5834\u5408\u3060\u3051\u5b9f\u884c\u3059\u308b<\/h2>\n<p><a href=\"#unlessEmpty\">unlessEmpty()<\/a>\u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.7.13 \u4ee5\u964d<\/em><\/p>\n<h1>\u30c7\u30fc\u30bf\u3092\u7d5e\u308a\u3053\u3080<\/h1>\n<h2>where()\u3067\u30c7\u30fc\u30bf\u3092\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u30c7\u30fc\u30bf\u306e\u4e2d\u304b\u308920\u6b73\u306e\u4eba\u3060\u3051\u3092\u7d5e\u308a\u8fbc\u3080\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 16],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 20],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 27],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 20],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 23]\r\n]<\/strong>);\r\n$filtered = $collection-&gt;<strong>where('age', 20)<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            <strong>[age] =&gt; 20<\/strong>\r\n        )\r\n\r\n    [3] =&gt; Array\r\n        (\r\n            [id] =&gt; 4\r\n            [name] =&gt; \u5c71\u672c\r\n            <strong>[age] =&gt; 20<\/strong>\r\n        )\r\n\r\n)\r\n<\/pre>\n<h2>whereStrict()\u3067\u30c7\u30fc\u30bf\u3092\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p>where()\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u6bd4\u8f03\u306e\u65b9\u6cd5\u304c\u3088\u308a\u53b3\u683c\u306a\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u578b\u3082\u8003\u616e\u3057\u305f\u6bd4\u8f03\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre>if(<strong>$a === $b<\/strong>) {}<\/pre>\n<p>\u203b\u4f7f\u3044\u65b9\u306f<a href=\"#where\">where()<\/a>\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<h2>whereIn()\u3067\u8907\u6570\u306e\u8a72\u5f53\u30c7\u30fc\u30bf\u3092\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p>\u4f8b\u3048\u3070\u300120\u6b73\u306823\u6b73\u306e\u4f1a\u54e1\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 16],<\/strong>\r\n<strong>    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 20],<\/strong>\r\n<strong>    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 27],<\/strong>\r\n<strong>    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 20],<\/strong>\r\n<strong>    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 23]<\/strong>\r\n<strong>]<\/strong>);\r\n$filtered = $collection-&gt;<strong>whereIn('age', [20, 23])<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [1] =&gt; Array\r\n        (\r\n            [id] =&gt; 2\r\n            [name] =&gt; \u4f50\u85e4\r\n            <strong>[age] =&gt; 20<\/strong>\r\n        )\r\n\r\n    [3] =&gt; Array\r\n        (\r\n            [id] =&gt; 4\r\n            [name] =&gt; \u5c71\u672c\r\n            <strong>[age] =&gt; 20<\/strong>\r\n        )\r\n\r\n    [4] =&gt; Array\r\n        (\r\n            [id] =&gt; 5\r\n            [name] =&gt; \u85e4\u539f\r\n            <strong>[age] =&gt; 23<\/strong>\r\n        )\r\n\r\n)\r\n<\/pre>\n<h2>whereInStrict()\u3067\u30c7\u30fc\u30bf\u3092\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p><a href=\"#whereIn\">whereIn()<\/a>\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u6bd4\u8f03\u306e\u65b9\u6cd5\u304c\u3088\u308a\u53b3\u683c\u306a\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u578b\u3082\u8003\u616e\u3057\u305f\u6bd4\u8f03\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre>if(<strong>$a === $b<\/strong>) {}<\/pre>\n<p>\u203b\u4f7f\u3044\u65b9\u306f<a href=\"#whereIn\">whereIn()<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>whereNotIn()\u3067\u6307\u5b9a\u30c7\u30fc\u30bf\u4ee5\u5916\u306b\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p><a href=\"#whereIn\">whereIn()<\/a>\u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002\u3064\u307e\u308a\u3001\u6307\u5b9a\u3057\u305f\u30c7\u30fc\u30bf\u300c<strong>\u4ee5\u5916<\/strong>\u300d\u306e\u3082\u306e\u3060\u3051\u306b\u7d5e\u308a\u8fbc\u3080\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u4f8b\u3048\u3070\u300120\u6b73\u306823\u6b73\u300c<strong>\u4ee5\u5916<\/strong>\u300d\u306e\u4f1a\u54e1\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 16],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 20],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 27],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 20],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 23]\r\n]);\r\n$filtered = $collection-&gt;<strong>whereNotIn('age', [20, 23])<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n        (\r\n            [id] =&gt; 1\r\n            [name] =&gt; \u9234\u6728\r\n            <strong>[age] =&gt; 16<\/strong>\r\n        )\r\n\r\n    [2] =&gt; Array\r\n        (\r\n            [id] =&gt; 3\r\n            [name] =&gt; \u7530\u4e2d\r\n            <strong>[age] =&gt; 27<\/strong>\r\n        )\r\n\r\n)\r\n<\/pre>\n<h2>whereNotInStrict()\u3067\u6307\u5b9a\u30c7\u30fc\u30bf\u4ee5\u5916\u306b\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p><a href=\"#whereNotIn\">whereNotIn()<\/a>\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u6bd4\u8f03\u306e\u65b9\u6cd5\u304c\u3088\u308a\u53b3\u683c\u306a\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u578b\u3082\u8003\u616e\u3057\u305f\u6bd4\u8f03\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre>if(<strong>$a === $b<\/strong>) {}<\/pre>\n<p>\u203b\u4f7f\u3044\u65b9\u306f<a href=\"#whereNotIn\">whereNotIn()<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>whereInstanceOf()\u3067\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3069\u3046\u304b\u3067\u7d5e\u308a\u8fbc\u3080<\/h2>\n<p>\u3069\u306e\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u7d5e\u308a\u8fbc\u307f\u3092\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(<strong>[<\/strong>\r\n<strong>    \\App\\User::find(1),<\/strong>\r\n<strong>    new \\App\\User,<\/strong>\r\n<strong>    new \\App\\Item,<\/strong>\r\n<strong>]<\/strong>);\r\n$filtered = $collection-&gt;<strong>whereInstanceOf(\\App\\User::class)<\/strong>;<\/pre>\n<p>\u3053\u306e\u4f8b\u3067\u53d6\u5f97\u3067\u304d\u308b\u306e\u306f\u30011\u3064\u76ee\u30682\u3064\u76ee\u306e\u30c7\u30fc\u30bf\u3067\u3059\u3002<\/p>\n<h2>whereBetween()\u3067\uff12\u3064\u306e\u5024\u306e\u9593\u306b\u3042\u308b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u300120\u301c30\u624d\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 18],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 28],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 30],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 25],\r\n]);\r\n$filtered = $collection-&gt;<strong>whereBetween('age', [20, 30])<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [1] =&gt; Array\r\n    (\r\n        [id] =&gt; 2\r\n        [name] =&gt; \u4f50\u85e4\r\n        [age] =&gt; 28\r\n    )\r\n    \r\n    [2] =&gt; Array\r\n    (\r\n        [id] =&gt; 3\r\n        [name] =&gt; \u7530\u4e2d\r\n        [age] =&gt; 20\r\n    )\r\n    \r\n    [3] =&gt; Array\r\n    (\r\n        [id] =&gt; 4\r\n        [name] =&gt; \u5c71\u672c\r\n        [age] =&gt; 30\r\n    )\r\n    \r\n    [4] =&gt; Array\r\n    (\r\n        [id] =&gt; 5\r\n        [name] =&gt; \u85e4\u539f\r\n        [age] =&gt; 25\r\n    )\r\n\r\n)<\/pre>\n<p>\u203b<code>age &gt;= 20<\/code>\u3001<code>age &lt;= 30<\/code>\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p style=\"text-align: right;\"><em>Laravel 5.7.19 \u4ee5\u964d<\/em><\/p>\n<h2>whereNotBetween()\u3067\uff12\u3064\u306e\u5024\u306e\u9593\u306f\u300c\u306a\u3044\u300d\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n<p><a href=\"#whereBetween\">whereBetween()<\/a> \u306e\u9006\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 18],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; 28],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; 30],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 25],\r\n]);\r\n$filtered = $collection-&gt;<strong>whereNotBetween('age', [20, 30])<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n    (\r\n        [id] =&gt; 1\r\n        [name] =&gt; \u9234\u6728\r\n        [age] =&gt; 18\r\n    )\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 5.7.19 \u4ee5\u964d<\/em><\/p>\n<h2>whereNull()\u3067Null\u306e\u30c7\u30fc\u30bf\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u304c<code>null<\/code>\u306e\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', 'age' =&gt; 18],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; <strong>null<\/strong>],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', 'age' =&gt; 20],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; <strong>null<\/strong>],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', 'age' =&gt; 25],\r\n]);\r\n$filtered = $collection-&gt;<strong>whereNull('age')<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [1] =&gt; Array\r\n    (\r\n        [id] =&gt; 2\r\n        [name] =&gt; \u4f50\u85e4\r\n        [age] =&gt; \r\n    )\r\n\r\n    [3] =&gt; Array\r\n    (\r\n        [id] =&gt; 4\r\n        [name] =&gt; \u5c71\u672c\r\n        [age] =&gt; \r\n    )\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 6.15 \u4ee5\u964d<\/em><\/p>\n<h2>whereNotNull()\u3067Null\u300c\u4ee5\u5916\u300d\u30c7\u30fc\u30bf\u3060\u3051\u53d6\u5f97\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5e74\u9f62\u304c<code>null<\/code><strong>\u300c\u4ee5\u5916\u300d<\/strong>\u306e\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    ['id' =&gt; 1, 'name' =&gt; '\u9234\u6728', <strong>'age' =&gt; 18<\/strong>],\r\n    ['id' =&gt; 2, 'name' =&gt; '\u4f50\u85e4', 'age' =&gt; null],\r\n    ['id' =&gt; 3, 'name' =&gt; '\u7530\u4e2d', <strong>'age' =&gt; 20<\/strong>],\r\n    ['id' =&gt; 4, 'name' =&gt; '\u5c71\u672c', 'age' =&gt; null],\r\n    ['id' =&gt; 5, 'name' =&gt; '\u85e4\u539f', <strong>'age' =&gt; 25<\/strong>],\r\n]);\r\n$filtered = $collection-&gt;<strong>whereNotNull('age')<\/strong>;\r\nprint_r($filtered-&gt;toArray());<\/pre>\n<p>\u7d50\u679c\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Array\r\n(\r\n    [0] =&gt; Array\r\n    (\r\n        [id] =&gt; 1\r\n        [name] =&gt; \u9234\u6728\r\n        [age] =&gt; 18\r\n    )\r\n\r\n    [2] =&gt; Array\r\n    (\r\n        [id] =&gt; 3\r\n        [name] =&gt; \u7530\u4e2d\r\n        [age] =&gt; 20\r\n    )\r\n    \r\n    [4] =&gt; Array\r\n    (\r\n        [id] =&gt; 5\r\n        [name] =&gt; \u85e4\u539f\r\n        [age] =&gt; 25\r\n    )\r\n)<\/pre>\n<p style=\"text-align: right;\"><em>Laravel 6.15 \u4ee5\u964d<\/em><\/p>\n<h1>\u305d\u306e\u4ed6<\/h1>\n<h2>macro()\u3067\u72ec\u81ea\u306eCollection\u30e1\u30bd\u30c3\u30c9\u3092\u3064\u304f\u308b<\/h2>\n<p>\u72ec\u81ea\u306e<code>Collection<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u308a\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u540d\u524d\u306e\u5f8c\u306b\u300c\u69d8\u300d\u3092\u3064\u3051\u308b\u72ec\u81ea\u30e1\u30bd\u30c3\u30c9<code>sir()<\/code>\u3067\u3059\u3002<\/p>\n<pre>Collection::<strong>macro('sir', function($key){<\/strong>\r\n\r\n<strong>    return $this-&gt;get($key) .' \u69d8';<\/strong>\r\n\r\n<strong>})<\/strong>;<\/pre>\n<p>\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u3001\u7b2c\uff11\u5f15\u6570\u306b\u30e1\u30bd\u30c3\u30c9\u540d\u3001\u7b2c\uff12\u5f15\u6570\u306b\u72ec\u81ea\u30c7\u30fc\u30bf\u3092\u8fd4\u3059<code>function(){ ... }<\/code>\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002\uff08\u3069\u3053\u304b\u3089\u3067\u3082\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b<strong>AppServiceProvider.php<\/strong> \u306b\u3067\u3082\u8a18\u8ff0\u3059\u308c\u3070\u3044\u3044\u3067\u3057\u3087\u3046\uff09<\/p>\n<p>\u4f7f\u3044\u65b9\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$collection = collect([\r\n    'id' =&gt; 1,\r\n    <strong>'name' =&gt; '\u9234\u6728',<\/strong>\r\n    'age' =&gt; 20\r\n]);\r\necho $collection-&gt;<strong>sir('name')<\/strong>; \/\/ \u9234\u6728 \u69d8<\/pre>\n<h2>make()\u3067Collection\u3092\u3064\u304f\u308b<\/h2>\n<p>\u65b0\u3057\u3044\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = <strong>Collection::make(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f'])<\/strong>;<\/pre>\n<p>\u305f\u3060\u3001\u500b\u4eba\u7684\u306b\u306f\u30b3\u30fc\u30c9\u91cf\u304c\u5c11\u306a\u3044\u30d8\u30eb\u30d1\u30fc\u95a2\u6570<code>collect()<\/code>\u3092\u4f7f\u3046\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<pre>$collection = <strong>collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f'])<\/strong>;<\/pre>\n<h2>tap()\u3067\u9014\u4e2d\u7d4c\u904e\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/h2>\n<p><code>Collection<\/code>\u306e\u69cb\u9020\u3092\u3044\u304f\u3064\u304b\u5909\u5316\u3055\u305b\u308b\u9014\u4e2d\u3067\u300c\u30c7\u30fc\u30bf\u304c\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u304b\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u5834\u5408\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre>$collection = collect(['\u9234\u6728', '\u4f50\u85e4', '\u7530\u4e2d', '\u5c71\u672c', '\u85e4\u539f']);\r\n$collection-&gt;sort()\r\n    -&gt;<strong>tap(function($collection){<\/strong>\r\n\r\n<strong>        \/\/ \u4e26\u3079\u66ff\u3048\u305f\u76f4\u5f8c\u306e\u72b6\u6cc1\u3092\u30c1\u30a7\u30c3\u30af<\/strong>\r\n<strong>        print_r($collection-&gt;toArray());<\/strong>\r\n\r\n<strong>    })<\/strong>\r\n    -&gt;shuffle();<\/pre>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u5f53\u521d\u306f\u305d\u308c\u307b\u3069\u3053\u306e\u8a18\u4e8b\u3092\u4f5c\u6210\u3059\u308b\u306e\u306b\u6642\u9593\u304c\u304b\u304b\u308b\u3068\u306f\u601d\u3063\u3066\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u7d50\u679c\u3068\u3057\u3066\uff08\u30d5\u30eb\u3067\u306f\u306a\u3044\u306b\u3057\u3066\u3082\uff093\u65e5\u307b\u3069\u6642\u9593\u304c\u304b\u304b\u308a\u6700\u7d42\u7684\u306b4\u4e07\u6587\u5b57\u3092\u8d8a\u3048\u308b\u3053\u3068\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002^^;\uff08\u8ffd\u8a18\u3067\uff15\u4e07\u6587\u5b57\u3092\u8d85\u3048\u307e\u3057\u305f\ud83d\ude05\uff09<\/p>\n<p>\u305f\u3060\u3001\u65b0\u3057\u3044\u767a\u898b\u3092\u305f\u304f\u3055\u3093\u767a\u898b\u3057\u305f\u306e\u3067\u958b\u767a\u8005\u3068\u3057\u3066\u306f\u30d7\u30e9\u30b9\u306b\u306a\u3063\u305f\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307f\u306a\u3055\u3093\u3082\u6642\u77ed\uff06\u53ef\u8aad\u6027\u306e\u826f\u3044\u30b3\u30fc\u30c9\u306e\u305f\u3081\u306b\u305c\u3072\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u3002<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-444 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/16.png\" alt=\"\" width=\"370\" height=\"310\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/16.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/16-300x251.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><span style=\"text-align: center; font-size: 1rem;\">\u3055\u3059\u304c\u306b\u3061\u3087\u3063\u3068\u75b2\u308c\u307e\u3057\u305f\u30fb\u30fb\u30fbzzz<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u4ee5\u524d\u300cLaravel\u306e\u4fbf\u5229\u306a\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30fb\u30e1\u30bd\u30c3\u30c9\uff17\u9078\uff01\u300d\u3092\u516c\u958b\u3057\u305f\u6642\u304b\u3089\u3044\u3064\u304b\u3084\u308a\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u304c\u3001 \u5168Laravel Collection\u30e1\u30bd &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=727\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u5168117\u7a2e\u985e\uff01Laravel 5.6\u301c7.x\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5b9f\u4f8b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":729,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[65],"class_list":["post-727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-65"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=727"}],"version-history":[{"count":35,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":6118,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions\/6118"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/729"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}