如何从格式的laravel刀片文件获取数组内部组件数据

时间:2019-10-30 06:45:11

标签: arrays json laravel

  

从laravel刀片文件访问阵列数据的问题

    @foreach($connbid as $conaccept)
        {{$conaccept->contributer_id}}<br>
             @foreach($conaccept['accept'] as $acceptpost)
                    {{ $acceptpost->bidpost_id }}<br>
                    {{ $acceptpost->customerpost->vehicle_booking->id }} //problem in accessing this 
                                                                           data from blade
             @endforeach
    @endforeach
  

原始json是:

[
  {
    "id": 1,
    "contributer_id": 2,
    "post_id": 1,
    "created_at": "2019-10-23 16:31:52",
    "updated_at": "2019-10-23 16:31:52",
    "accept": [
      {
        "id": 2,
        "user_id": 1,
        "customerpost": {
          "id": 1,
          "customer_id": 1,
          "vehicle_booking": {
            "id": 1,
            "vcustomeraccept": {
              "id": 1,
              "created_at": "2019-10-23 16:15:42",
              "updated_at": "2019-10-23 16:15:42",
              "customeraccept": null
            }
          }
        }
      }
    ]
]

1 个答案:

答案 0 :(得分:1)

如果$conaccept是一个数组,请尝试更改

$conaccept['accept']

$conaccept->accept