Find posts by their IDs, optionally making sure they are visible to a
certain user.

@param array $ids
@param \Flarum\User\User|null $actor
@return \Illuminate\Database\Eloquent\Collection
177538
public function findByIds(array $ids, User $actor = null)
    {
        $posts = $this->queryIds($ids, $actor)->get();

        $posts = $posts->sort(function ($a, $b) use ($ids) {
            $aPos = array_search($a->id, $ids);
            $bPos = array_search($b->id, $ids);

            if ($aPos === $bPos) {
                return 0;
            }

            return $aPos < $bPos ? -1 : 1;
        });

        return $posts;
    }
968208
public function actorlistJsonAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $actor = $em->getRepository('CoreBundle:Actor')->find($id);

        if (!$actor) {
            throw $this->createNotFoundException('Unable to find Actor entity.');
        }
        
        /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */
        $jsonList = $this->get('json_list');
        $jsonList->setRepository($em->getRepository('EcommerceBundle:Contract'));
        $jsonList->setActor($actor);
        $response = $jsonList->get();

        return new JsonResponse($response);
    }
739334
public function getIdsForUsername($string, User $actor = null)
    {
        $string = $this->escapeLikeString($string);

        $query = User::where('username', 'like', '%'.$string.'%')
            ->orderByRaw('username = ? desc', [$string])
            ->orderByRaw('username like ? desc', [$string.'%']);

        return $this->scopeVisibleTo($query, $actor)->pluck('id')->all();
    }
670096
public function findMany($ids, $columns = ['*'])
    {
        return empty($ids) ? [] : $this->whereIn(
            $this->getRelated()->getQualifiedKeyName(), $ids
        )->get($columns);
    }
96556
public function findMany($ids, array $columns = ['*'])
    {
        if (empty($ids)) {
            return $this->model->newCollection();
        }

        $this->getBuilder()->whereIn($this->getModel()->getQualifiedKeyName(), $ids);

        return $this->get($columns);
    }
23038
public function getActorIds()
    {
        $actorIds = $this->getValue('actorIds');

        if ($actorIds) {
            $actorIds = explode(',', $actorIds);
            $actorIds = array_unique($actorIds);
        } else {
            $actorIds = array();
        }

        return $actorIds;
    }
102324
public function getLists($ids = null, $args = array(), $returnRaw = false)
    {
        if ($ids) {
            $args['id'] = $ids;
        }

        return $this->getResult('getLists', $args, is_array($ids), $returnRaw);
    }
808231
private static function getItems($ids, $type)
    {
        $resultRCS = self::$client->request(
            'POST',
            self::BASEURL.'services/entreprise/rest/recherche/'.
            'resumeEntreprise?typeRecherche='.$type,
            [
                'json'    => $ids,
                'headers' => ['Content-Type' => 'text/plain'],
            ]
        );

        return json_decode($resultRCS->getBody())->items;
    }
219090
public function several(array $ids)
    {
        $results = [];
        foreach ($this->getEntry($ids) as $cacheId=>$entry) {
            if (!$this->isExpired($entry)) {
                $results[$cacheId] =  $this->getPayload($cacheId, $entry);
            }
        }

        return $results;
    }
1179807
public function findByIds($ids)
    {
        if (!is_array($ids)) {
            $ids = explode(',', $ids);
        }

        $items = $this->createValuedQueryBuilder('c')
            ->andWhere('c.id IN (:ids)')->setParameter('ids', $ids)
            ->andWhere('c.deletedAt IS NULL')
            ->getQuery()->useResultCache(true, self::CACHE_TTL)->getResult();

        return $this->sortByArray($items, $ids);
    }
411733
public function several(array $ids)
    {
        $results = [];

        foreach ($ids as $cacheId) {
            if ($this->cache->test($cacheId)) {
                $results[$cacheId] = $this->cache->load($cacheId);
            }

        }

        return $results;
    }
370797
public function where_id_in($ids)
        {
            return (Arrays::is($this->_getIdColumnName())) ?
                $this->where_any_is($this->_getCompoundIdColumnValuesArray($ids)) :
                $this->where_in($this->_getIdColumnName(), $ids);
        }
204240
public static function find($ids, $columns = ['*'])
    {
        $me = new self;
        $query = $me->newQuery();

        foreach ($me->getKeyName() as $key) {
            $query->where($key, '=', $ids[$key]);
        }

        return $query->first($columns);
    }
282825
public function findOrFail($id, User $actor = null)
    {
        $query = Group::where('id', $id);

        return $this->scopeVisibleTo($query, $actor)->firstOrFail();
    }
54652
public function findByName($name, User $actor = null)
    {
        $query = Group::where('name_singular', $name)->orWhere('name_plural', $name);

        return $this->scopeVisibleTo($query, $actor)->first();
    }
289551
public function resetStats($actors)
    {
        foreach ($actors as $actor) {
            $ids = $actor->notificationIds->toArray();
            $ids = $this->getService('repos:notifications.notification')->getQuery()->id($ids)->fetchValues('id');
            $actor->set('notificationIds', AnDomainAttribute::getInstance('set')->setData($ids));
            $new_ids = array();

            foreach ($actor->newNotificationIds as $id) {
                if (in_array($id, $ids)) {
                    $new_ids[] = $id;
                }
            }

            $actor->set('newNotificationIds', AnDomainAttribute::getInstance('set')->setData($new_ids));
        }
    }
713737
public function getCommonLeaders($actor)
    {
        if (!isset($this->__common_leaders)) {
            $ids = array_intersect($this->leaderIds->toArray(), $actor->leaderIds->toArray());
            $ids[] = -1;
            $query = $this->getService('repos:actors.actor')->getQuery()->where('id', 'IN', $ids);

            $this->__common_leaders = $query->toEntitySet();
        }

        return $this->__common_leaders;
    }