mardi 25 juin 2019

Using collection with filter return model objects

In my laravel 5.7 I use collection with filter, but I would liek to return not integer value I set to this filter, but model objects on filtered values, like :

$selectedSubscriptions = collect($tempSelectedSubscriptions)->filter(function ($item) {
    $nextTempSelectedSubscription = SiteSubscription::find($item);
    if ($nextTempSelectedSubscription !== null) {
        return (object)['id' => $nextTempSelectedSubscription->id, 'name' => $nextTempSelectedSubscription->name];
    }
});

How can I do this ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Fwsih2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire