diff --git a/src/Jenssegers/Mongodb/Schema/Builder.php b/src/Jenssegers/Mongodb/Schema/Builder.php index 8dddb62dc..e30e162b7 100644 --- a/src/Jenssegers/Mongodb/Schema/Builder.php +++ b/src/Jenssegers/Mongodb/Schema/Builder.php @@ -106,6 +106,16 @@ public function drop($collection) return $blueprint->drop(); } + /** + * @inheritdoc + */ + public function dropAllTables() + { + foreach ($this->getAllCollections() as $collection) { + $this->drop($collection); + } + } + /** * @inheritdoc */ @@ -113,4 +123,19 @@ protected function createBlueprint($collection, Closure $callback = null) { return new Blueprint($this->connection, $collection); } + + /** + * Get all of the collections names for the database. + * + * @return array + */ + protected function getAllCollections() + { + $collections = []; + foreach ($this->connection->getMongoDB()->listCollections() as $collection) { + $collections[] = $collection->getName(); + } + + return $collections; + } }