whereIn('accounts.id', $ids) ->where('user_id', Auth::user()->id) ->get(['accounts.*']); if ($object->count() > 0) { return $object; } } throw new NotFoundHttpException; } /** * @param array $ids * * @return array */ protected static function filterIds(array $ids): array { $new = []; foreach ($ids as $id) { if (intval($id) > 0) { $new[] = $id; } } $new = array_unique($new); return $new; } }