You can use ->map()->values()
over your grouped data like
$collection = collect([
"2021-02-26"=>[
"id"=>2,
"week_season"=> 1,
"week_number"=>1,
"m_hour"=> "21:31:28",
"m_date"=> "2021-02-26",
],
"2021-02-27"=> [
"id"=> 7,
"week_season"=> 1,
"week_number"=>1,
"m_hour"=> "21:37:04",
"m_date"=>"2021-02-27",
]
]);
$results = $collection->map(function ($item, $key) {
return ["date"=> $key, "matches"=>$item];
})->values();
echo "<pre>";
print_r($results->toArray());
echo "</pre>";
which will produce output as
Array
(
[0] => Array
(
[date] => 2021-02-26
[matches] => Array
(
[id] => 2
[week_season] => 1
[week_number] => 1
[m_hour] => 21:31:28
[m_date] => 2021-02-26
)
)
[1] => Array
(
[date] => 2021-02-27
[matches] => Array
(
[id] => 7
[week_season] => 1
[week_number] => 1
[m_hour] => 21:37:04
[m_date] => 2021-02-27
)
)
)
Finally it will look something like
$mdate = Match::all()
->groupBy('m_date');
->map(function ($item, $key) {
return ["date"=> $key, "matches"=>$item];
})->values();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…