0

我正在尝试重用对 has-many-Relationship 的调用,如下所示:

//myModelEntries is the has-many-Relationship
$entries = $myModel->myModelEntries();

$firstUseCase = $entries
                   //->where(...)
                   //->select(...)
                   //->get()
                   //->map(...)
                   //->all()

$secondUseCase = $entries
                   // append some other querybuilder functions

遗憾的是$entries不能以这种方式重用,因为第一次使用会以某种方式改变$entries变量。因此,我第二次使用$entries此变量时的行为方式与此不同$myModel->myModelEntries()

完成这项工作的最佳方法是什么?

4

0 回答 0