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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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.7k
Taking Flight with Tailwind CSS
opdavies
0
5.6k
TDD - Test Driven Drupal
opdavies
0
4.4k
Building "Build Configs"
opdavies
0
660
Communities and contribution
opdavies
0
370
Working without Workspace
opdavies
0
420
Things you should know about PHP
opdavies
1
940
An Introduction to Mob Programming
opdavies
0
480
Deploying PHP applications with Ansible, Ansible Vault and Ansistrano
opdavies
0
6.7k
Other Decks in Technology
See All in Technology
変更差分を読むために環境を整備しよう
pipepasta
1
470
閉域網でのAPI公開の選択肢全部比較!
takano0131
4
560
[NW-JAWS DAY]「うちのAWS、インターネット出られないんで」― AWS外の自社サービスをPrivateLinkでシュッと公開する方法
ykimi
3
860
コピーオンライト型ファイルシステムと ランダム書き込み
sat
PRO
2
130
Sonnetだけで業務はまわる?
kintotechdev
1
150
E2E Test というハーネス — AI時代の自動テスト民主化
daishukojima
10
5.7k
メルカリの小規模チーム「Pod」で、 エンジニアがデータアナリストなしで、 AIを使ってデータ分析の自走を目指す取り組み
jackojacko_
0
110
Del vibe coding a un Desarrollo (agéntico) fiable
jcabot
0
160
契約書SaaSにAIエージェントを組み込む
sansantech
PRO
0
190
CloudTrail を推したい
kazzpapa3
1
140
WasmをRustにする技術
sansantech
PRO
1
120
AI時代における医療情報システムのセキュリティ / Security of Healthcare IT Systems in the AI Era
henryofficial
0
190
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
540
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Utilizing Notion as your number one productivity tool
mfonobong
4
650
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
810
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.3k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
380
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k