<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>nakahashi_h</author_name>
  <author_url>https://blog.hatena.ne.jp/nakahashi_h/</author_url>
  <blog_title>websandbag ブログ</blog_title>
  <blog_url>https://blog.websandbag.com/</blog_url>
  <categories>
    <anon>laravel</anon>
  </categories>
  <description>プロジェクトが複雑になればなるほど、データベースを用いたやりとりの難易度も上がっていきます。 複数のテーブルをリレーションさせる事はよくあります。 Laravelではリレーション周りの関数も色々用意されており、複雑なリレーションにも柔軟に対応できます。 さて、 今回はリレーションされた要素数を扱いたい場合の方法について記載します。 実装仕様 例えば、ブログサービスを作るとします。 仕様上、ブログの記事にはカテゴリが１つ付与されています。 今回実現したいことは、カテゴリ毎の登録データ数を取得したいです。 テーブル構成 次のようなテーブル構成だったとします。 記事（entries） 記事カテゴリ（…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.websandbag.com%2Fentry%2F2020%2F11%2F16%2F023337&quot; title=&quot;【Laravel】リレーションされた要素数を取得する - websandbag ブログ&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>https://cdn-ak.f.st-hatena.com/images/fotolife/n/nakahashi_h/20180506/20180506160600.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-11-16 02:33:37</published>
  <title>【Laravel】リレーションされた要素数を取得する</title>
  <type>rich</type>
  <url>https://blog.websandbag.com/entry/2020/11/16/023337</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
