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
Laravel ViewComposer
Search
Takayuki
June 14, 2019
Programming
1
290
Laravel ViewComposer
Laravel ViewComposer
Takayuki
June 14, 2019
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
120
地方カンファレンス主催のススメ
bumptakayuki
1
160
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
790
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
530
沖縄観光、名物を一挙紹介!
bumptakayuki
2
540
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.8k
flutterでイベントアプリを作ってみた
bumptakayuki
0
110
オフショア開発の辛みと学んだ事
bumptakayuki
0
340
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
170
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
150
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Functional Event Sourcing using Sekiban
tomohisa
0
110
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
Better Code Design in PHP
afilina
PRO
0
130
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
350
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
4
2k
Featured
See All Featured
Designing for humans not robots
tammielis
250
25k
Designing for Performance
lara
604
68k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
BBQ
matthewcrist
85
9.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Facilitating Awesome Meetings
lara
50
6.1k
Transcript
Laravel view composer Laravel view composer
3 ࣮ํ๏ Agenda 2 View composerͱ 1 ࣗݾհ
1 ࣗݾհ
4 ࣗݾհ ◆໊લ ླ ೭(Suzuki Takayuki) ◆ࣗݾհ ɾ1990ɺਆಸݝੜ·Εɻ ɾࣾձਓʹͳ͔ͬͯΒɺϓϩάϥϛϯάΛ࢝ΊΔɻ ɾ2015ʹϑϧεϐʔυʹೖࣾ͠ɺ2017ʹϑϦʔϥ
ϯεΛͬͨޙʹ201711݄ʹԭೄͰىۀɻ ◆झຯ ίεϓϨɺԻָϥΠϒɺϚϥιϯେձʹग़Δɺٿ؍ ઓ ◆Twitter @kanbo0605
Copyright Re:Build.inc All Rights Reserved. 1.ձࣾհ ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ ԭೄݝԭೄࢢதԝ̍ஸ̍̒−̕
◆ࣄۀ༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ◆ࣾһ 5໊ ◆ΤϯδχΞͷಇ͖ํ ϦϞʔτϫʔΫՄೳͳࣗ༝ͳಇ͖ํΛਪͯ͠·͢ʂ
6 ࣗࣾWebαʔϏεͷ։ൃ ɾαʔϏε໊ Tadoru ɾγεςϜ֓ཁ Ϋϥυιʔγϯά ΫϨδοτܾࡁ ͳͲ ɾ͍ͬͯΔٕज़ ݴޠ
: PHP,JavaScript ϑϨʔϜϫʔΫ: laravel5,Nuxt.jsͳͲ
2 View composerͱ
8 2 View composerͱ ϏϡʔίϯϙʔβϏϡʔ͕Ϩϯμʔ͞ ΕΔ࣌ʹݺͼग़͞ΕΔɺίʔϧόοΫ͔ Ϋϥεϝιουͷ͜ͱͰ͢ɻ Ϗϡʔ͕Ϩϯμʔ͞ΕΔͨͼʹ݁߹ͨ͠ ͍ใ͕͋ΔͳΒɺϏϡʔίϯϙʔβ͕
ϩδοΫΛҰՕॴʹ·ͱΊΔͷʹཱͪ ·͢ɻ https://readouble.com/laravel/5.5/ja/views.html Controller View Router HTMLΛฦ٫ HTML viewϑΝΠϧʹ มΛόΠϯυ /mypageΞΫηε ViewComposer ڞ௨ͰόΠϯυͨ͠ ͍มΛ·ͱΊΔ ※શମͷΠϝʔδͷҝɺ ࡉ͔͍෦লུ͍ͯ͠·͢ɻ
9 ͲΜͳ࣌ʹ͏ͷ͔ʁ ɾαΠυόʔͳͲͯ͢ͷϖʔδͰڞ௨͢ΔσʔλΛද͍ࣔͨ࣌͠ɻ ɾϏϡʔϩδοΫͰ͖Είϯτϩʔϥʔʹॻ͖ͨ͘ͳ͍͠ɺςϯϓ ϨʔτͰ͖Δ͚ͩϩδοΫΛೖΕͣɺ៉ྷͳhtmlͷ··Ͱ͋Γ͍ͨɻ ɾίϯτϩʔϥʔͷංେԽΛ͍͗ͨɻ https://readouble.com/laravel/5.5/ja/views.html
3 ࣮ํ๏
11 γεςϜͷػೳཁ݅ ɾڞ௨ͰuserใΛ͍ճ͍ͯ͠Δ ɾϔομʔͷbladeϑΝΠϧҎ֎ͰαΠυόʔͳͲͷՕॴͰ userใΛ͍͍ͨ
$loginUserใΛ ༻ $loginUserใΛ ༻ $loginUserใΛ ༻
1 3 ࣮ͨ͠༰ ᶃαʔϏεϓϩόΠμʔͷ༻ҙ ᶄapp/config.phpʹొ ᶅComposerΫϥεͷ࡞ ᶆSeriviceProviderͷઃఆ ᶇbladeϑΝΠϧͷमਖ਼ http://vdeep.net/laravel-viewcomposer
1 4 ᶃαʔϏεϓϩόΠμʔͷ༻ҙ $ php artisan make:provider ViewComposerServiceProvider Λ࣮ߦͯ͠ɺαʔϏεϓϩόΠμʔΛੜ ͢Δ
1 5 ᶄapp/config.phpʹొ ʮconfig/app.phpʯԼهͷΑ͏ ʹSeriviceProviderΛొ͢Δ
1 6 ᶅComposerΫϥεͷ࡞ ʮapp/Http/ViewComposersʯͱ͍͏ ܗ Ͱ σ Ο Ϩ Ϋ
τ Ϧ Λ ࡞ ͠ ɺ ViewComposersσΟϨΫτϦͷதʹ ʮLayoutComposer.phpʯΛ࡞͠· ͢ɻ
1 7 ᶆSeriviceProviderͷઃఆ bootϝιουʹViewComposer͕ Λ͢viewΛɺView::composersϝ ιουΛͬͯࢦఆ͠·͢ɻ
1 8 ᶇbladeϑΝΠϧͷमਖ਼ $loginUserͷมΛ֘Օॴʹ ॻ͘
1 9 ᶇbladeϑΝΠϧͷमਖ਼ $loginUserͷมΛ֘Օॴʹ ॻ͘
2 0 ᶇbladeϑΝΠϧͷमਖ਼ $loginUserͷมΛ֘Օॴʹ ॻ͘
2 1 ࠂ 10/12 PHPΧϯϑΝϨϯεԭೄ։࠵͠·͢ʂ