src/Model/Collection.php
public function only($keys)
    {
        if ($keys === null) {
            return new static($this->objects);
        }

        $keys = is_array($keys) ? $keys : func_get_args();

        return new static(array_intersect_key($this->objects, array_flip($keys)));
    }
public function only($keys)
    {
        if ($keys === null) {
            return new static($this->objects);
        }

        $keys = is_array($keys) ? $keys : func_get_args();

        return new static(array_intersect_key($this->objects, array_flip($keys)));
    }
public function only ( $ keys ) { if ( $ keys === null ) { return new static ( $ this -> objects ) ; } $ keys = is_array ( $ keys ) ? $ keys : func_get_args ( ) ; return new static ( array_intersect_key ( $ this -> objects , array_flip ( $ keys ) ) ) ; }
Extract the objects with the specified keys.

@param  mixed $keys One or more object primary keys.
@return static
Extract the objects with the specified keys .