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 Activity Logを使って簡単に変更履歴機能を実装しよう
Search
Takayuki
January 15, 2022
Programming
0
790
Laravel Activity Logを使って簡単に変更履歴機能を実装しよう
変更履歴の機能を実装するのって、考慮する事も多いし、大変ですよね?
Laravel Activity Logを使うと、簡単に変更履歴の機能を実装できます。
Takayuki
January 15, 2022
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
87
地方カンファレンス主催のススメ
bumptakayuki
1
140
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
660
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
490
沖縄観光、名物を一挙紹介!
bumptakayuki
2
500
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.6k
flutterでイベントアプリを作ってみた
bumptakayuki
0
100
オフショア開発の辛みと学んだ事
bumptakayuki
0
330
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
150
Other Decks in Programming
See All in Programming
複雑さに立ち向かうための ソフトウェア開発入門
shiz
3
620
Wallet API, Verifier APIで実現するIDカード on iPhoneの世界
shitamori1272
1
340
大公開!iOS開発の悩みトップ5 〜iOSDC Japan 2024〜
ryunakayama
0
180
Why Prism?
kddnewton
4
510
Mergeable Libraryで 高速なアプリ起動を実現しよう!
giginet
PRO
1
2k
New Order in Cascade Sorting Order
mugi_uno
3
2.5k
ウォンテッドリーにおけるモバイルアプリ開発 / iOSDC Japan 2024 Sponsor Session
kubode
0
230
ゲームボーイアドバンスでSwiftを動かそう
k_koheyi
0
520
ECMAScript、Web標準の型はどう管理されているか / How ECMAScript and Web standards types are maintained
petamoriken
3
370
Ruby Parser progress report 2024
yui_knk
2
190
BasicBasic認証
sadnessojisan
5
2.7k
React + TextAliveでカッコいいLyric Applicatioinを作ろう!!
tosuri13
0
330
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
48
13k
Teambox: Starting and Learning
jrom
131
8.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
45
4.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
25
5k
How GitHub Uses GitHub to Build GitHub
holman
472
290k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Robots, Beer and Maslow
schacon
PRO
157
8.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
28
2.2k
Optimizing for Happiness
mojombo
375
69k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
190
16k
Web development in the modern age
philhawksworth
204
10k
Transcript
鈴木孝之 Laravel Activity LogΛͬͯ؆୯ ʹมߋཤྺػೳΛ࣮͠Α͏
"HFOEB ࣗݾհɾձࣾհ มߋཤྺػೳ։ൃͷ՝ Γ͍ͨࣄ ࣮ํ๏
Copyright Re:Build.inc All Rights Reserved. ରऀʹ͍ͭͯ 0 -BSBWFMͷجૅ͕ࣝ͋Δ ॳڃऀʙதڃऀ͚
ࣗݾհɾձࣾհ
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 0 ◆໊લ ླ ೭(Suzuki
Takayuki) ※ಉಉ໊ଟͯ͘ࠔͬͯ·͢ɻɻɻ ◆ࣗݾհ ɾ1990ੜ·Εɻ ɾΤϯδχΞˠϑϦʔϥϯεˠԭೄͰىۀ ɾPHPΧϯϑΝϨϯεԭೄ࣮ߦҕһɺ ϑϩϯτΤϯυΧϯϑΝϨϯεԭೄ࣮ߦҕһ ◆झຯ ίεϓϨɺԻָϥΠϒɺϚϥιϯେձʹग़Δɺٿ؍ઓ BDD(Ϗʔνۦಈ։ൃ)
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 1
Copyright Re:Build.inc All Rights Reserved. ധ̏Ͱ։࠵ʂࣾ֎ͷํ ߹ಉͰ։ൃͯ͠·͢ʂ ϦϏϧυԭೄ։ൃ߹॓ 0
Copyright Re:Build.inc All Rights Reserved. ϦϏϧυԭೄ։ൃ߹॓ 0
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 0
Copyright Re:Build.inc All Rights Reserved. ձࣾհ 0 ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ
ԭೄݝಹࢢٱໜ2-2-2 λΠϜεϏϧ ◆ࣄۀ༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ɾϓϩάϥϛϯάεΫʔϧ ◆ࣾһ 12໊ ΤϯδχΞืूͯ͠·͢ʂʂʂ
มߋཤྺػೳ։ൃͷ՝
Copyright Re:Build.inc All Rights Reserved. มߋཤྺػೳ։ൃͷ՝ - มߋཤྺͷػೳΛ࣮͢Δͷͬͯɺߟྀ͢Δࣄଟ͍͠ɺେ มͰ͢ΑͶʁ -
Laravel Activity LogΛ͏ͱɺ؆୯ʹมߋཤྺͷػೳΛ࣮ Ͱ͖·͢ɻ 1
Copyright Re:Build.inc All Rights Reserved. 1 มߋཤྺػೳ։ൃͷ՝ DBઃܭ͕େม શػೳͷૢ࡞มߋཤྺΛ ͢ͱͳΔͱɺӨڹൣғ
͕͍ มߋཤྺͷ෮ݩ͕͍͠
Γ͍ͨࣄ
Copyright Re:Build.inc All Rights Reserved. Γ͍ͨ͜ͱ - σʔλͷ࡞ɾߋ৽ɾআͷϢʔβ ͷಈ࡞ʹରͯ͠ཤྺΛ͍ͨ͠ɻ -
มߋཤྺσʔλΛը໘ʹදࣔͨ͠ ͍ɻ - ޙͰཤྺσʔλΛ෮ݩͰ͖ΔΑ͏ʹ ͓͖͍ͯͨ͠ɻ 2
࣮ํ๏
Copyright Re:Build.inc All Rights Reserved. ͏ύοέʔδ 3 https://github.com/spatie/laravel-activitylog ͜ͷspatie/laravel-activitylogύοέʔδɺ ϢʔβʔͷΞΫςΟϏςΟΛϩάʹه͢Δͨ
Ίͷ͍͍ؔ͢Λఏڙ͠·͢ɻϞσϧΠϕ ϯτΛࣗಈతʹϩάʹه͢Δ͜ͱͰ͖· ͢ɻ laravel-activitylogͱʁ
Copyright Re:Build.inc All Rights Reserved. ͏ύοέʔδ 3 https://github.com/spatie/laravel-activitylog - มߋରͷରDBΛه
- มߋ͕͋ͬͨࡍͷઆ໌จΛه - มߋલͱมߋޙͷσʔλͷࠩΛه laravel-activitylogͰग़དྷΔࣄ
Copyright Re:Build.inc All Rights Reserved. 1.ύοέʔδͷΠϯετʔϧ 3 ԼهͷίϚϯυΛ࣮ߦ͢Δ $ composer
require spatie/laravel-activitylog $ php artisan vendor:publish -- provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog- migrations"
Copyright Re:Build.inc All Rights Reserved. 2.ϚΠάϨʔγϣϯͷ࣮ߦ 3 migrateΛ࣮ߦͯ͠activity_logςʔϒϧΛ࡞ ͠·͢ɻ $
php artisan migrate
Copyright Re:Build.inc All Rights Reserved. 3.Modelͷमਖ਼ 3 useͰLogsActivityΛࢦఆ͢ΔͷͱɺgetActivitylogOptions()ͷؔʹมߋཤྺʹ͍ͨ͠ΧϥϜΛࢦఆ͠·͢ɻ
Copyright Re:Build.inc All Rights Reserved. 4.Controllerͷमਖ਼ 3 - activity()ͰରͷModelࢦఆ͠·͢ɻ -
causedBy()Ͱߋ৽࡞ۀΛ࣮ߦ͢Δ ϢʔβΛࢦఆ͠·͢ɻ - log()ͰDBͷdescriptionʹೖΔ༰Λ ఆٛ͠·͢ɻ
Copyright Re:Build.inc All Rights Reserved. ొ͞ΕΔσʔλͷྫ 3 ͋ͱDBʹొ͞ΕͨσʔλΛऔಘ͠ ͯɺද͍ࣔͤͨ͞ը໘ʹදࣔͤ͞Ε OKͰ͢ʂ
มߋͨ͠ σʔλ ը໘ʹදࣔ͢ Δཤྺͷจষ
Copyright Re:Build.inc All Rights Reserved. ·ͱΊ - Laravel-activitylogΛ͏ͱɺσʔλͷ࡞ɾߋ৽ɾআͳ ͲͷϢʔβͷಈ࡞ʹରͯ͠ͷཤྺΛ؆୯ʹهͰ͖Δʂ -
ͨͩɺಠࣗͷཁ͕݅͋ΔΑ͏ͳ։ൃͩͱɺΧελϚΠζʹ ݶք͕͋Γͦ͏ɻ
Copyright Re:Build.inc All Rights Reserved. ࠂ 20225݄ࠒʹPHPΧϯϑΝϨϯεԭೄΛ։࠵༧ఆͰ͢ʂ ※ίϩφΠϧεͷঢ়گʹΑͬͯɺมߋʹͳΔՄೳੑ͕͋Γ·͢ɻ