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

Relearning Eloquent

0892871036578feecfa18893d1062e6d?s=47 zuckey_17
March 08, 2018

Relearning Eloquent

0892871036578feecfa18893d1062e6d?s=128

zuckey_17

March 08, 2018
Tweet

More Decks by zuckey_17

Other Decks in Programming

Transcript

  1. Eloquentͷ࢖͍ํΛߟ͑௚ͨ͠ 2018/03/08@Laravel Meetup Tokyo Vol.10

  2. Introduction •zuckey •developer •ϑϩϯτΤϯυ, αʔόαΠυ •React, PHP, Laravel •twitter: @zuckey_17

    •Podcastʮ͕͠ͳ͍ϥδΦʯύʔιφϦςΟʔ •https://shiganai.org
  3. •EloquentΛ࢖͏ཧ༝Λ͸͖ҧ͍͑ͯͨ •ጻչ •͓ͦΒ͘͜ͷ৔ͷଟ͘ͷਓʹͱͬͯ͸౰ͨΓલ

  4. Eloquent ͱ๻ͷؔΘΓ •SQLite => MySQL΁ͷҠߦ •ૉͷSQLΛهड़ •ORMΛ࢖ͬͯDBΛԾ૝తʹଊ͍͑ͨ ORM = ͱΓ͋͑ͣSQLΛ࢖Θͳ͍΋ͷ͘Β͍ʹࢥ͍ͬͯͨ

  5. None
  6. ;ͱɺϒϩάͰॻ͍ͨίʔυ

  7. ;ͱɺϒϩάͰॻ͍ͨίʔυ $table ͸͍Βͳ͍ $fillable ͸͍Βͳ͍ ؾܰʹtoArray͠ͳ͍ େྔͷࢦఠ ʘ(^o^)ʗ

  8. id key title description url published_at episodes id episode_id text

    url episode_contents id episode_id cast_id episode_casts name twitter_screen_name image_url type casts 1 ର ଟ ଟ ର ଟ ྫ͑͹͜͏͍͏ςʔϒϧͰ
  9. JSON͕΄͍͠

  10. with ඍົͳ஌ࣝ ΫΤϦͷճ਺ര૿

  11. ORM https://qiita.com/yk-nakamura/items/acd071f16cda844579b9

  12. ศརͳ API Λ࢖͏ •EagerϩʔυͰΫΤϦճ਺Λগͳ͘ •σʔλྔ͕૿͑ΔͱtoArray΋അࣛʹͳΒͳ͍ •࿈૝഑ྻͷkeyΛมߋ͚ͨ͠Ε͹શ෦Ҿ͍͔ͯΒ

  13. ·ͱΊ •DB΁ͷΞΫηεΛORMܦ༝ʹ
 ஔ͖׵͑Δ͚ͩͰ͸͋·Γ͏·Έ͕ͳ͍ •ೖΕΔͷ΋ίετͳͷͰɺ
 ࢖͍౗͞ͳ͍ͱٯʹෛ࠴ʹͳͬͯ͠·͏

  14. એ఻ •https://shiganai.org