我在Laravel 有Collection :
Collection {#450 ▼
#items: array:2 [▼
0 => Announcement {#533 ▶}
1 => Announcement {#553 ▶}
]
}
都是一样的东西.我如何删除其中一个?
Full code is:
public function announcements()
{
$announcements = $this->categories_ann->map(function ($c) {
return $c->announcements->map(function ($a) {
$a->subsribed = true;
return $a;
});
});
$flattened = $announcements->groupBy("id")->flatten();
return $flattened;
}