Laravel Collection get unique values from nested datastructure
问题 I want to use Laravel 5.1 Collection's Unique method to filter unique IDs from nested objects. Given the data structure { "key1": [ {"id": 1}, {"id": 1} ], "key2": [ {"id": 1}, {"id": 2} ] } I want to return the same datastructure with duplicate id 1 removed from "key 1". I wanted to use $unique = $collection->unique('id'); , but this doesn't seem to apply to a nested datastructure as I have. So I thought to use $collection $input = $request->all(); $collection = collect($input); $collection-