3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravelでサブクエリをメソッド使いたい。joinSub()

Last updated at Posted at 2018-12-09

laravelでサブクエリをつかいたい。

DB::rawを使って生sqlでサブクエリを読み込ませる方法が過去あったが、5.6からjoinSubというメソッドができたらしい


$hoges = DB::table('hoge')
             ->where('fuga')
             ->select('piyo');

function hogeGet () : object
{
    return DB::table('hogehoge')
            ->joinSub($hoges,'hoges', function ($join) {
                $join->on('hogehoge.id', '=', 'hoges.hogehoge_id');
            })
            ->get();
}

Laravel News
Laravel 5.6.17 Released
https://laravel-news.com/laravel-5-6-17

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?