我如何在Laravel中编写嵌套查询

时间:2019-01-13 15:49:29

标签: laravel laravel-5

val root = (project in file(".")).settings(Seq(
  assemblyMergeStrategy in assembly := {
    case PathList("application.conf") => MergeStrategy.discard
    case PathList("assembly.conf") => new MyMergeStrategy()
    case x =>
      val oldStrategy = (assemblyMergeStrategy in assembly).value
      oldStrategy(x)
  }
))

这是我想在laravel中查询以获取数据的查询,我该如何在laravel中写出

1 个答案:

答案 0 :(得分:3)

这应该有效:

$result = DB::table('posts')
    ->whereIn('user_id', function ($query) {
        $query->select('following')
            ->from('follows')
            ->where('user_id', 1);
    })->get();