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
840
Laravel Activity Logを使って簡単に変更履歴機能を実装しよう
変更履歴の機能を実装するのって、考慮する事も多いし、大変ですよね?
Laravel Activity Logを使うと、簡単に変更履歴の機能を実装できます。
Takayuki
January 15, 2022
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
110
地方カンファレンス主催のススメ
bumptakayuki
1
150
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
750
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
520
沖縄観光、名物を一挙紹介!
bumptakayuki
2
530
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.7k
flutterでイベントアプリを作ってみた
bumptakayuki
0
110
オフショア開発の辛みと学んだ事
bumptakayuki
0
340
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
160
Other Decks in Programming
See All in Programming
EventSourcingの理想と現実
wenas
6
2.1k
カスタムしながら理解するGraphQL Connection
yanagii
1
1.2k
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
VR HMDとしてのVision Pro+ゲーム開発について
yasei_no_otoko
0
100
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
Outline View in SwiftUI
1024jp
1
120
Java ジェネリクス入門 2024
nagise
0
600
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
1.7k
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
200
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
23
11k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
210
Featured
See All Featured
The Language of Interfaces
destraynor
154
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Thoughts on Productivity
jonyablonski
67
4.3k
KATA
mclloyd
29
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Typedesign – Prime Four
hannesfritz
39
2.4k
Producing Creativity
orderedlist
PRO
341
39k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
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ΧϯϑΝϨϯεԭೄΛ։࠵༧ఆͰ͢ʂ ※ίϩφΠϧεͷঢ়گʹΑͬͯɺมߋʹͳΔՄೳੑ͕͋Γ·͢ɻ