Commit b464c2f0 authored by Marko Vodanović's avatar Marko Vodanović Committed by Jens Segers

Fix for index names (#1137)

- fixed possiblilty to specify index names when creating them
- also fixed docstring comments so code completion works
  properly when using IDEs
parent fa4a5351
...@@ -7,14 +7,14 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint ...@@ -7,14 +7,14 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/** /**
* The MongoConnection object for this blueprint. * The MongoConnection object for this blueprint.
* *
* @var MongoConnection * @var \Jenssegers\Mongodb\Connection
*/ */
protected $connection; protected $connection;
/** /**
* The MongoCollection object for this blueprint. * The MongoCollection object for this blueprint.
* *
* @var MongoCollection * @var \Jenssegers\Mongodb\Collection|\MongoDB\Collection
*/ */
protected $collection; protected $collection;
...@@ -32,7 +32,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint ...@@ -32,7 +32,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
{ {
$this->connection = $connection; $this->connection = $connection;
$this->collection = $connection->getCollection($collection); $this->collection = $this->connection->getCollection($collection);
} }
/** /**
...@@ -54,6 +54,10 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint ...@@ -54,6 +54,10 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
$columns = $transform; $columns = $transform;
} }
if ($name !== null) {
$options['name'] = $name;
}
$this->collection->createIndex($columns, $options); $this->collection->createIndex($columns, $options);
return $this; return $this;
...@@ -64,7 +68,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint ...@@ -64,7 +68,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
*/ */
public function primary($columns = null, $name = null, $algorithm = null, $options = []) public function primary($columns = null, $name = null, $algorithm = null, $options = [])
{ {
return $this->unique($columns, $options); return $this->unique($columns, $name, $algorithm, $options);
} }
/** /**
...@@ -102,7 +106,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint ...@@ -102,7 +106,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
$options['unique'] = true; $options['unique'] = true;
$this->index($columns, null, null, $options); $this->index($columns, $name, $algorithm, $options);
return $this; return $this;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment