尝试读取数组laravel视图循环foreach上的属性“data_audit”

laik7k3q  于 2023-10-22  发布在  其他
关注(0)|答案(1)|浏览(101)

大家好,我希望有人能帮助我,我不明白为什么我有这个错误。我在视图中的刀片的@foreach中做错了什么?非常感谢,这是我的代码。
返回:

$audits = DB::table('esiti_audit')->where('employee', $name)->select(['master_zone', 'subarea', 'microarea', 'data_audit', 'esito'])->orderByDesc('data_audit')->get()->toArray();

$data = [];

foreach ($audits as $audit) {

 $areaKey =  "{$audit->master_zone}|{$audit->subarea}|{$audit->microarea}";

                $data[$areaKey][] = [
                    'esito' => $audit->esito,
                    'data_audit' => $audit->data_audit
                ];
            };
        };

<div class="audit-daily-intestazione">
                                            @if (empty($data))
                                            @else
                                                @foreach ($data as $item => $audits)
                                                <div>
                                                    <span class="audit-daily-text39"><strong
                                                            style="font-size: 13px;">{{ \Carbon\Carbon::parse($audits->data_audit)->format('d/m') }}</strong></span>
                                                </div>
                                                @endforeach
                                            @endif
                                        </div>

oknwwptz

oknwwptz1#

试试这个

<div class="audit-daily-intestazione">
    @if (!empty($data))
        @foreach ($data as $item => $audits)
            <div>
                @foreach ($audits as $audit)
                    <span class="audit-daily-text39">
                    <strong style="font-size: 13px;">
                        {{ \Carbon\Carbon::parse($audit['data_audit'])->format('d/m') }}
                    </strong>
                </span>
                @endforeach
            </div>
        @endforeach
    @endif
</div>

相关问题