LoginSignup
1
0

More than 3 years have passed since last update.

function($query)を使って条件しぼってwhereInにぶっこむ

Last updated at Posted at 2019-11-18
public function getArticleEditors()
    {
        return $this->model->whereIn('staff.id', function($query) {
            $query->from('article')
                ->selectRaw('distinct article.assigned_user_id');
        })
            ->select('staff.id', 'staff.name')
            ->get();
    }

最後にget()をつかうとcollectionクラスのオブジェクト(中身はmodelクラス)になって、get()を省略すると、builderクラスのオブジェクトになる。

1
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
1
0