<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>shonansurvivors</author_name>
  <author_url>https://blog.hatena.ne.jp/shonansurvivors/</author_url>
  <blog_title>やんばるテック</blog_title>
  <blog_url>https://blog.shonansurvivors.com/</blog_url>
  <categories>
    <anon>Laravel</anon>
  </categories>
  <description>はじめに 多対多の関係の中間テーブルのモデルはPivot化すると、リレーション経由でアクセスしやすくなります。 中間テーブルのモデルにメソッドを持たせていて、それを使いたい場合に便利です。 目次 はじめに 目次 Pivot化していない場合 Pivot化する 補足 参考 Pivot化していない場合 例として、Itemモデルに、多対多の関係にあるTagモデルが存在し、以下のような多対多のリレーションが定義されているとします。 class Item extends Model { public function tags(): BelongsToMany { return $this-&gt;belong…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.shonansurvivors.com%2Fentry%2Flaravel-pivot&quot; title=&quot;【Laravel】多対多の中間テーブルのモデルはPivot化するとアクセスしやすくなりメソッドを使いやすい - やんばるテック&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2019-06-09 00:00:00</published>
  <title>【Laravel】多対多の中間テーブルのモデルはPivot化するとアクセスしやすくなりメソッドを使いやすい</title>
  <type>rich</type>
  <url>https://blog.shonansurvivors.com/entry/laravel-pivot</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
