Laravel中的方法链接何时需要变量重新分配?

我想了解为什么在下面的代码中,两种变体都有效:

  1. $draws = $draws->where('domain_id', $id); and
  2. $draws->where('domain_id', $id); (without reassigning the variable $draw)
    $draws = Draw::query();

    if ($condition)
        $draws->where('domain_id', $id); // <-- I used to call $draws = $draws->where('domain_id', $id);

    $draws = $draws->paginate(10);

I was under the assumption that I always had to reassign the variable $draws to make it work.

在Laravel中,什么时候不需要重新分配变量?

评论