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
850
Laravel Activity Logを使って簡単に変更履歴機能を実装しよう
変更履歴の機能を実装するのって、考慮する事も多いし、大変ですよね?
Laravel Activity Logを使うと、簡単に変更履歴の機能を実装できます。
Takayuki
January 15, 2022
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
Remix on Hono on Cloudflare Workers
yusukebe
1
300
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Outline View in SwiftUI
1024jp
1
330
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.5k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
630
Featured
See All Featured
Writing Fast Ruby
sferik
627
61k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Embracing the Ebb and Flow
colly
84
4.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Typedesign – Prime Four
hannesfritz
40
2.4k
For a Future-Friendly Web
brad_frost
175
9.4k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Making Projects Easy
brettharned
115
5.9k
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ΧϯϑΝϨϯεԭೄΛ։࠵༧ఆͰ͢ʂ ※ίϩφΠϧεͷঢ়گʹΑͬͯɺมߋʹͳΔՄೳੑ͕͋Γ·͢ɻ