0

我有SaleInvoice模型,销售发票属于User模型,User模型属于另一个名为Client. 在User模型上,我使用急切加载来加载Client

class User extends Authenticatable
{

    /**
     * The relations to eager load on every query.
     *
     * @var array
     */
    protected $with = ['client'];
}

问题是,当我渴望加载User模型SaleInvoice时,它也会加载Client

class SaleInvoice extends Model
{

    /**
     * The relations to eager load on every query.
     *
     * @var array
     */
    protected $with = ['user'];
}

** 有没有办法只加载Userwith SaleInvoiceClient注意:加载也很重要User

4

0 回答 0