Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laravel Activity Logを使って簡単に変更履歴機能を実装しよう

Takayuki
January 15, 2022

Laravel Activity Logを使って簡単に変更履歴機能を実装しよう

変更履歴の機能を実装するのって、考慮する事も多いし、大変ですよね?
Laravel Activity Logを使うと、簡単に変更履歴の機能を実装できます。

Takayuki

January 15, 2022
Tweet

More Decks by Takayuki

Other Decks in Programming

Transcript

  1. Copyright Re:Build.inc All Rights Reserved. ࣗݾ঺հ 0 ◆໊લ ླ໦ ޹೭(Suzuki

    Takayuki) ※ಉ੏ಉ໊ଟͯ͘ࠔͬͯ·͢ɻɻɻ ◆ࣗݾ঺հ ɾ1990೥ੜ·Εɻ ɾΤϯδχΞˠϑϦʔϥϯεˠԭೄͰىۀ ɾPHPΧϯϑΝϨϯεԭೄ࣮ߦҕһ௕ɺ ϑϩϯτΤϯυΧϯϑΝϨϯεԭೄ࣮ߦҕһ௕ ◆झຯ ίεϓϨɺԻָϥΠϒɺϚϥιϯେձʹग़Δɺ໺ٿ؍ઓ BDD(Ϗʔνۦಈ։ൃ)
  2. Copyright Re:Build.inc All Rights Reserved. ձࣾ঺հ 0 ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ

    ԭೄݝಹ೼ࢢٱໜ஍2-2-2 λΠϜεϏϧ ◆ࣄۀ಺༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ɾϓϩάϥϛϯάεΫʔϧ ◆ࣾһ 12໊ ΤϯδχΞืूͯ͠·͢ʂʂʂ
  3. Copyright Re:Build.inc All Rights Reserved. ΍Γ͍ͨ͜ͱ - σʔλͷ࡞੒ɾߋ৽ɾ࡟আͷϢʔβ ͷಈ࡞ʹରͯ͠ཤྺΛ࢒͍ͨ͠ɻ -

    มߋཤྺσʔλΛը໘ʹදࣔͨ͠ ͍ɻ - ޙͰཤྺσʔλΛ෮ݩͰ͖ΔΑ͏ʹ ͓͖͍ͯͨ͠ɻ 2
  4. Copyright Re:Build.inc All Rights Reserved. ࢖͏ύοέʔδ 3 https://github.com/spatie/laravel-activitylog - มߋର৅ͷର৅DBΛه࿥

    - มߋ͕͋ͬͨࡍͷઆ໌จΛه࿥ - มߋલͱมߋޙͷσʔλͷࠩ෼Λه࿥ laravel-activitylogͰग़དྷΔࣄ
  5. 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"
  6. Copyright Re:Build.inc All Rights Reserved. 4.Controllerͷमਖ਼ 3 - activity()Ͱର৅ͷModelࢦఆ͠·͢ɻ -

    causedBy()Ͱߋ৽࡞ۀΛ࣮ߦ͢Δ ϢʔβΛࢦఆ͠·͢ɻ - log()ͰDBͷdescriptionʹೖΔ಺༰Λ ఆٛ͠·͢ɻ