イントロダクションIntroduction
Illuminate\Support\Collectionクラスは、配列データを操作するための、書きやすく使いやすいラッパーです。以下の例をご覧ください。配列から、新しいコレクションインスタンスを作成するために、collectヘルパを使用しています。The Illuminate\Support\Collection class provides a fluent, convenient wrapper for working with arrays of data. For example, check out the following code. We'll use the collect helper to create a new collection instance from the array:
$collection = collect(['taylor', 'abigail', null])->map(function($name)
{
	return strtoupper($name);
})
->reject(function($name)
{
	return is_null($value);
});
ご覧の通り、Collectionクラスは、裏にある配列をマップし要素削除するメソッドをチェーンでスムーズにつなげてくれます。つまり、全てのCollectionメソッドは、新しいCollectionインスタンスを返します。より掘り下げますので、続けて読み進めてください!As you can see, the Collection class allows you to chain its methods to perform fluent mapping and reducing of the underlying array. In general, every Collection method returns an entirely new Collection instance. To dig in further, keep reading!
基本的な使用法Basic Usage
コレクションの生成Creating Collections
上記の通り、collectヘルパは指定された配列を元に、新しいIlluminate\Support\Collectionインスタンスを返します。また、Collectionクラスのmakeメソッドを使うこともできます。As mentioned above, the collect helper will return a new Illuminate\Support\Collection instance for the given array. You may also use the make command on the Collection class:
$collection = collect([1, 2, 3]);
$collection = Collection::make([1, 2, 3]);
もちろん、Eloquentオブジェクトのコレクションは、いつもCollectionインスタンスを返します。しかし、アプリケーションで便利に使えるなら、どこででもCollectionクラスを自由に使ってください。Of course, collections of Eloquent[/docs/master/eloquent] objects are always returned as Collection instances; however, you should feel free to use the Collection class wherever it is convenient for your application.
コレクションの詳細Explore The Collection
コレクションで使用できるメソッド全部(たくさんあります)をここではリストしません。代わりに、クラスのAPIドキュメントをご覧ください。Instead of listing all of the methods (there are a lot) the Collection makes available, check out the API documentation for the class[http://laravel.com/api/master/Illuminate/Support/Collection.html]!