在我的laravel 5.7中,我将集合与过滤器一起使用,但是我想返回的不是设置为此过滤器的整数值,而是 根据过滤后的值对对象进行建模,例如:
$selectedSubscriptions = collect($tempSelectedSubscriptions)->filter(function ($item) {
$nextTempSelectedSubscription = SiteSubscription::find($item);
if ($nextTempSelectedSubscription !== null) {
return (object)['id' => $nextTempSelectedSubscription->id, 'name' => $nextTempSelectedSubscription->name];
}
});
我该怎么做?