J'aime parler d'une collection comme d'un super-tableau.
Comme dans un tableau, on y retrouve plusieurs informations. En plus, la classe de la collection nous offre une foule de méthodes et de propriétés pour nous aider à travailler avec ces informations.
Laravel offre deux principales classes nommées Collection :
Il est possible de transformer une collection Eloquent en collection de base en appelant la méthode toBase().
« Eloquent: Collections ». Laravel. https://laravel.com/docs/master/eloquent-collections
« Collections ». Laravel. https://laravel.com/docs/master/collections
« Laravel Collections: PHP Arrays On Steroids ». Scotch.io. https://scotch.io/tutorials/laravel-collections-php-arrays-on-steroids
« How Laravel Collections lead to Zen Code ». Medium. https://medium.com/@mattkingshott/how-laravel-collections-lead-to-zen-code-966c1fa7b03d
« Two Types of Collections in Laravel ». Medium. https://medium.com/@lynnlin827/two-types-of-collections-in-laravel-888d43858c4e
« How to manually create a new empty Eloquent Collection in Laravel 4 ». Stack Overflow. http://stackoverflow.com/questions/23599584/how-to-manually-create-a-new-empty-eloquent-collection-in-laravel-4
▼Publicité