使用Sum函数调用未定义方法的Laravel
Laravel 8及其最新更新 客户有许多机器,机器有许多帐户记录 这项工作{{machines.accounts}}使用Sum函数调用未定义方法的Laravel,laravel,eloquent,eloquent-relationship,Laravel,Eloquent,Eloquent Relationship,Laravel 8及其最新更新 客户有许多机器,机器有许多帐户记录 这项工作{{machines.accounts}} Route::get('/', function () { return Customer::with([ 'machines', 'machines.accounts', 'user' ]) ->get(); }); 但是with sum()或with count()不起作用 Route:
Route::get('/', function () {
return Customer::with([
'machines',
'machines.accounts',
'user'
])
->get();
});
但是with sum()或with count()不起作用
Route::get('/', function () {
return Customer::with([
'machines',
'user'
])
->withSum('machines.accounts', 'credit')
->get();
});
错误:调用未定义的方法App\Models\Customer::machines.accounts()使用with('machines',callback)和inside add withSum()不使用2次
with
和with
只使用1次with
或with sum
2次with work,但当它与