双查询生成器关系表中的行代码出现Laravel错误



Hello,我在中得到了意外的"(",应为"{">

这是我在刀片中的代码:

@foreach($invoices as $invoice)
{{$invoice->userinvoiceperson->(function($userinvoiceperson) {return $userinvoiceperson->user->name;})}}
@endforeach

这是我在控制器中的代码:

$invoices = Invoice::with(['userinvoiceperson' => function($query){
$query->with('user')->get();
}])->with('userinvoicesubaccount')->where('validate','=',0)->whereBetween('updated_at', [$date1, $date2])->get();

关系船舶结构

与具有userinvoiceperson函数的person_id中的人员相关的发票。具有用户功能的user_id中与用户相关的人。

我错过了哪里?非常感谢。

编辑:相反,这行代码完美地工作

{{$account->subaccount->sum( function($subaccount) { return $subaccount->subaccountinvoice->sum('amount');})}}

我不得不写

{{$invoice->userinvoiceperson->user->name}}

谢谢

最新更新