Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Using Laravel Collections... Outside Laravel
Search
Oliver Davies
August 28, 2018
Technology
2.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Using Laravel Collections... Outside Laravel
Oliver Davies
August 28, 2018
More Decks by Oliver Davies
See All by Oliver Davies
Building Static Websites with Sculpin
opdavies
0
1.7k
Taking Flight with Tailwind CSS
opdavies
0
5.5k
TDD - Test Driven Drupal
opdavies
0
4.3k
Building "Build Configs"
opdavies
0
610
Communities and contribution
opdavies
0
320
Working without Workspace
opdavies
0
350
Things you should know about PHP
opdavies
1
900
An Introduction to Mob Programming
opdavies
0
430
Deploying PHP applications with Ansible, Ansible Vault and Ansistrano
opdavies
0
6.6k
Other Decks in Technology
See All in Technology
ヘルスケア領域における AI 活用と その安全性担保のための取り組み (Leveraging AI in Healthcare and Our Efforts to Ensure Its Safety) - Google I/O Extended Tokyo 2026, July 11, 2026
zettaittenani
0
270
「最後に責任を取るのはチーム」— 人間のPRレビューを最小化してアップデートしたメンタルモデル
jnishime_dresscode
0
550
クラウド上のデータ復旧で見落としがちな制約: 医療系 SaaS の BCP 設計から得た教訓
kakehashi
PRO
0
3.4k
最適な自走を最小限の支援で — M&Aで拡大する組織で少人数SREが挑んだ1年 / SRE NEXT 2026
genda
0
1.1k
Claude Code公式skillで 自分の仕事を少しずつ手放そう!(Claude Code開発ノウハウ大公開スペシャル by クラスメソッド)
kaym
1
250
穢れた技術選定について
watany
3
310
依頼文化をやめる日 EM視点で語るPlatform EngineeringとInclusive SRE / Discussing Platform Engineering and Inclusive SRE from an EM's Perspective
shin1988
4
5.3k
AIレビューはどこまで任せられるのか?自動化と人が背負うレビューの境界
sansantech
PRO
2
710
KiCAD講習会②
tutcreators
0
110
Claude Code 珍プレー好プレー
shinyasaita
0
320
Mastraエージェント、どのクラウドにデプロイする?
minorun365
PRO
2
180
End-to-Endで考える信頼性 —LINEアプリにおけるクライアント開発×SRE連携の実践
maruloop
4
4.1k
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
Into the Great Unknown - MozCon
thekraken
41
2.6k
A designer walks into a library…
pauljervisheath
211
24k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
310
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
750
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Transcript
USING LARAVEL COLLECTIONS... OUTSIDE LARAVEL
COLLECTIONS
collect(['foo', 'bar']); // ['foo', 'bar'] collect('foobar'); // ['foobar'] $object =
new stdClass(); $object->foo = 'bar'; collect($object); // ['foo' => 'bar'] collect($object)->get('foo'); // bar
$collection = collect(['a', 'b', 1, 'c', 2, 'd', 'e', 3,
4]); $collection->count(); // 9 $collection->first(); // a $collection->first(function ($item) { return is_numeric($item); }); // 1 $collection->contains(2); // true $collection->contains([2, 10]); // false $collection->filter(function ($item) { return $item > 2; }); // [3, 4]
$collection = collect([ ['name' => 'John', 'email' => '
[email protected]
', 'age'
=> 31], ['name' => 'Jane', 'email' => '
[email protected]
', 'age' => 27], ]); $collection->pluck('name'); // ['John', 'Jane'] $collection->pluck('name')->sort(); // ['Jane', 'John'] $collection->filter(function ($person) { return $person['age'] >= 30; })->pluck('name'); // ['John']
None
THERE’S A MODULE FOR THAT! - DRUPALERS
THERE'S NOT A MODULE FOR THAT. - ME
None
VERSION 1.0 WRITE MY OWN COLLECTION CLASS
None
None
COLLECT - ILLUMINATE COLLECTIONS AS A SEPARATE PACKAGE. HTTPS://PACKAGIST.ORG/PACKAGES/TIGHTENCO/COLLECT
IMPORT LARAVEL'S COLLECTIONS INTO NON- LARAVEL PACKAGES EASILY, WITHOUT NEEDING
TO REQUIRE THE ENTIRE ILLUMINATE\SUPPORT PACKAGE. HTTPS://PACKAGIST.ORG/PACKAGES/TIGHTENCO/COLLECT
None
COMPOSER REQUIRE TIGHTENCO/COLLECT
None
None
VERSION 2.0 USE SOMEONE ELSE’S COLLECTION CLASS
None
▸ Install Composer ▸ Require tightenco/collect ▸ Include autoload.php ▸
collect() away!
▸ Install Composer ▸ Require tightenco/collect ▸ Include autoload.php ▸
collect() away!
// index.php require __DIR__ . '/vendor/autoload.php'; $collection = collect(['foo', 'bar']);
$collection->each(function ($item) { // Do something. });
None
None
None
THANKS! @OPDAVIES OLIVERDAVIES.UK