<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>webabc</author_name>
  <author_url>https://blog.hatena.ne.jp/webabc/</author_url>
  <blog_title>ABCウェブエンジニアblog</blog_title>
  <blog_url>https://webabc.hatenablog.jp/</blog_url>
  <categories>
    <anon>PHP&amp;Laravel</anon>
  </categories>
  <description>LaravelのEloquent ORMはSQLを意識せずデータベースを扱えてとても便利です。 ただリレーション先のカラムで主テーブルごとソートするのは一工夫必要。 一工夫というかクエリビルダの「JOIN」を使います！ //USERSのリレーション先のPLANSテーブルのTYPEカラムで並び替え $users = User::select('users.*') -&gt;join('plans', 'plans.user_id', '=', 'users.id') -&gt;orderBy('plans.type');</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwebabc.hatenablog.jp%2Fentry%2F2020%2F10%2F08%2F132937&quot; title=&quot;【Laravel6】リレーション先のカラムでソート - ABCウェブエンジニアblog&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.user.blog.st-hatena.com/default_entry_og_image/157593373/1602837464412779</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-10-08 13:29:37</published>
  <title>【Laravel6】リレーション先のカラムでソート</title>
  <type>rich</type>
  <url>https://webabc.hatenablog.jp/entry/2020/10/08/132937</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
