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
880
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
860
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
570
沖縄観光、名物を一挙紹介!
bumptakayuki
2
570
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
2k
flutterでイベントアプリを作ってみた
bumptakayuki
0
120
オフショア開発の辛みと学んだ事
bumptakayuki
0
350
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
180
Other Decks in Programming
See All in Programming
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
270
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
360
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
260
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
140
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
230
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
410
ATDDで素早く安定した デリバリを実現しよう!
tonnsama
1
1.2k
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
130
快速入門可觀測性
blueswen
0
480
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
410
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.1k
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
160
Featured
See All Featured
Done Done
chrislema
182
16k
Visualization
eitanlees
146
15k
Building Adaptive Systems
keathley
38
2.3k
For a Future-Friendly Web
brad_frost
176
9.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
230
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
171
50k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
940
Building Applications with DynamoDB
mza
92
6.1k
Faster Mobile Websites
deanohume
305
30k
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ΧϯϑΝϨϯεԭೄΛ։࠵༧ఆͰ͢ʂ ※ίϩφΠϧεͷঢ়گʹΑͬͯɺมߋʹͳΔՄೳੑ͕͋Γ·͢ɻ