Firestore/src/CollectionReference.php
public function add(array $fields = [], array $options = [])
    {
        $name = $this->randomName($this->name);

        $document = $this->documentFactory($name);
        $result = $document->create($fields, $options);

        return $document;
    }
public function add(array $fields = [], array $options = [])
    {
        $name = $this->randomName($this->name);

        $document = $this->documentFactory($name);
        $result = $document->create($fields, $options);

        return $document;
    }
public function add ( array $ fields = [ ] , array $ options = [ ] ) { $ name = $ this -> randomName ( $ this -> name ) ; $ document = $ this -> documentFactory ( $ name ) ; $ result = $ document -> create ( $ fields , $ options ) ; return $ document ; }
Generate a new document reference, and insert it with the given field data.

This method will generate a random document name. If you wish to create a
document with a specified name, create a reference with
{@see Google\Cloud\Firestore\CollectionReference::document()}, then call
{@see Google\Cloud\Firestore\DocumentReference::create()} to insert the
document.

This method immediately inserts the document. If you wish for lazy
creation of a Document instance, refer to
{@see Google\Cloud\Firestore\CollectionReference::document()} or
{@see Google\Cloud\Firestore\CollectionReference::newDocument()}.

Example:
```
$newUser = $collection->add([
'name' => 'Kate'
]);
```

@param array $fields An array containing field names paired with their value.
Accepts a nested array, or a simple array of field paths.
@param array $options Configuration Options.
@return DocumentReference
Generate a new document reference and insert it with the given field data .