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
870
Laravel Activity Logを使って簡単に変更履歴機能を実装しよう
変更履歴の機能を実装するのって、考慮する事も多いし、大変ですよね?
Laravel Activity Logを使うと、簡単に変更履歴の機能を実装できます。
Takayuki
January 15, 2022
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
130
地方カンファレンス主催のススメ
bumptakayuki
1
170
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
840
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
550
沖縄観光、名物を一挙紹介!
bumptakayuki
2
560
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.9k
flutterでイベントアプリを作ってみた
bumptakayuki
0
120
オフショア開発の辛みと学んだ事
bumptakayuki
0
350
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
180
Other Decks in Programming
See All in Programming
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
110
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
190
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
php-conference-japan-2024
tasuku43
0
320
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
460
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
情報漏洩させないための設計
kubotak
2
280
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
280
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
0
120
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
330
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
820
Zoneless Testing
rainerhahnekamp
0
120
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Making Projects Easy
brettharned
116
5.9k
The World Runs on Bad Software
bkeepers
PRO
65
11k
It's Worth the Effort
3n
183
28k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Rails Girls Zürich Keynote
gr2m
94
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
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ΧϯϑΝϨϯεԭೄΛ։࠵༧ఆͰ͢ʂ ※ίϩφΠϧεͷঢ়گʹΑͬͯɺมߋʹͳΔՄೳੑ͕͋Γ·͢ɻ