src/NodeRepository.php
public function getNodesByIds($ids, $published = true)
    {
        if (empty($ids))
        {
            return null;
        }

        if (is_string($ids))
        {
            $ids = json_decode($ids, true);
        }

        if (is_array($ids) && ! empty($ids))
        {
            $placeholders = implode(',', array_fill(0, count($ids), '?'));

            $nodes = Node::whereIn('id', $ids)
                ->orderByRaw('field(id,' . $placeholders . ')', $ids);

            if ($published)
            {
                $nodes->published();
            }

            $nodes = $nodes->get();

            return (count($nodes) > 0) ? $nodes : null;
        }

        return null;
    }
public function getNodesByIds($ids, $published = true)
    {
        if (empty($ids))
        {
            return null;
        }

        if (is_string($ids))
        {
            $ids = json_decode($ids, true);
        }

        if (is_array($ids) && ! empty($ids))
        {
            $placeholders = implode(',', array_fill(0, count($ids), '?'));

            $nodes = Node::whereIn('id', $ids)
                ->orderByRaw('field(id,' . $placeholders . ')', $ids);

            if ($published)
            {
                $nodes->published();
            }

            $nodes = $nodes->get();

            return (count($nodes) > 0) ? $nodes : null;
        }

        return null;
    }
public function getNodesByIds ( $ ids , $ published = true ) { if ( empty ( $ ids ) ) { return null ; } if ( is_string ( $ ids ) ) { $ ids = json_decode ( $ ids , true ) ; } if ( is_array ( $ ids ) && ! empty ( $ ids ) ) { $ placeholders = implode ( ',' , array_fill ( 0 , count ( $ ids ) , '?' ) ) ; $ nodes = Node :: whereIn ( 'id' , $ ids ) -> orderByRaw ( 'field(id,' . $ placeholders . ')' , $ ids ) ; if ( $ published ) { $ nodes -> published ( ) ; } $ nodes = $ nodes -> get ( ) ; return ( count ( $ nodes ) > 0 ) ? $ nodes : null ; } return null ; }
Returns nodes by ids

@param array|string $ids
@param bool $published
@return Collection
Returns nodes by ids