Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
Transcript
27 slides
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
More Decks by Oliver Davies
See All by Oliver Davies
Building Static Websites with Sculpin
opdavies
0
1.8k
Taking Flight with Tailwind CSS
opdavies
0
5.6k
TDD - Test Driven Drupal
opdavies
0
4.4k
Building "Build Configs"
opdavies
0
670
Communities and contribution
opdavies
0
370
Working without Workspace
opdavies
0
430
Things you should know about PHP
opdavies
1
950
An Introduction to Mob Programming
opdavies
0
490
Deploying PHP applications with Ansible, Ansible Vault and Ansistrano
opdavies
0
6.7k
Other Decks in Technology
See All in Technology
想定外の利用がプロダクトの価値を広げる
lycorptech_jp
PRO
0
110
メディアアートを〈拡張〉する——器官学と個体化論を手がかりに
_kotobuki_
0
370
Agent Routerで作るマルチテナント 推論基盤 #CNDW2026 / Building Multi-Tenant Inference Platform with Agent Router #CNDW2026
everpeace
5
650
gradle-best-practices 使ってみた
mikanichinose
0
240
その修正で本当に速くなったのか? k6とOpenTelemetryで確かめる性能改善 / Performance review with k6 and OpenTelemetry
ymotongpoo
3
470
Kiro Crew の Conductor mode: 1 つのチャットに渡したゴールを、コンダクターがワーカーに分けて任せる
inariku
PRO
1
130
Go でトランザクション、どう書いてますか?
knwoop
2
640
FPGAでアクティブセンシングがやりたくてカメラモジュールを自作した話
ryuz88
0
130
New Relicのアラート対応をClaude Codeで自動修正するワークフローを作った話
manabuseki
3
730
フルTypeScript × AI駆動開発で開発量が数倍に (JSConf JP 2026 スポンサーLT:NCDC株式会社)
keitaibaraki
0
440
ノードが消える前提で設計する!Karpenterで金融システムを止めないためのノウハウ大全
daitak
1
260
統制されたID・権限をどう利用するか : DPoP/FAPIによるAPIセキュリティ強化
oidfj
2
340
Featured
See All Featured
New Earth Scene 8
popppiees
5
2.9k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
620
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
530
How STYLIGHT went responsive
nonsquared
100
6.4k
Visualization
eitanlees
153
17k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
360
Scaling GitHub
holman
464
140k
Typedesign – Prime Four
hannesfritz
42
3.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k