我如何从Laravel雄辩的多级数组中获取数据?

时间:2019-01-30 07:17:29

标签: php laravel-5 group-by eloquent

我的问题是关于从多级数组中获取数据,这是从Laravel Groupby方法(Eloquent)生成的。

数组

array:1 [▼
  1 => array:3 [▼
    4 => array:1 [▼
      2 => array:7 [▼
        0 => array:7 [▶]
        1 => array:7 [▶]
        2 => array:7 [▶]
        3 => array:7 [▶]
        4 => array:7 [▶]
        5 => array:7 [▶]
        6 => array:7 [▶]
      ]
    ]
    3 => array:1 [▼
      1 => array:1 [▼
        0 => array:7 [▶]
      ]
    ]
    2 => array:1 [▼
      1 => array:1 [▼
        0 => array:7 [▶]
      ]
    ]
  ]
]

实际上我的数据表是这样的

{
  "2": {
    "1": [
      {
        "id": 9,
        "technology_id": 1,
        "subject_id": 7,
        "session_id": 2,
        "semester_id": 1,
        "created_at": "2019-01-18 18:18:27",
        "updated_at": "2019-01-18 18:18:27"
      }
    ]
  },
  "3": {
    "1": [
      {
        "id": 8,
        "technology_id": 1,
        "subject_id": 1,
        "session_id": 3,
        "semester_id": 1,
        "created_at": "2019-01-18 18:18:27",
        "updated_at": "2019-01-18 18:18:27"
      }
    ]
  },
  "4": {
    "2": [
      {
        "id": 1,
        "technology_id": 1,
        "subject_id": 20,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      },
      {
        "id": 2,
        "technology_id": 1,
        "subject_id": 23,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      },
      {
        "id": 3,
        "technology_id": 1,
        "subject_id": 24,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      },
      {
        "id": 4,
        "technology_id": 1,
        "subject_id": 45,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      },
      {
        "id": 5,
        "technology_id": 1,
        "subject_id": 46,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      },
      {
        "id": 6,
        "technology_id": 1,
        "subject_id": 47,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      },
      {
        "id": 7,
        "technology_id": 1,
        "subject_id": 48,
        "session_id": 4,
        "semester_id": 2,
        "created_at": "2019-01-18 18:16:49",
        "updated_at": "2019-01-18 18:16:49"
      }
    ]
  }
}

我希望html中的视图如此-

https://imgur.com/a/O03Iog0

有人可以帮忙吗?

0 个答案:

没有答案