Converting an array of arrays from Laravel's collection into an object with an array in json
- 阅读更多 关于 Converting an array of arrays from Laravel's collection into an object with an array in json
问题 I am generating an an array of categories and subcategories in my Laravel API for use in my client side app. I'm doing this by using the collection's filter and map methods to organize the data pulled from the database: // get the data from the category table $categoryData = $categories->all()->categories(); // filter the data by category names we know we want and create the multi-dimensional array of the fields we need $categoryList = $categoryData->filter(function ($value) { return $value[