Add credentials to MongoDB constructor

- Reverted the config changes
- The credentials are now added to the MongoDB constructor if they are not already present
- Also fixed failing test by changing method access level
parent 38c91036
......@@ -117,10 +117,10 @@ And add a new mongodb connection:
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'options' => [
'db' => 'admin', // sets the authentication database required by mongo 3
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'db' => 'admin' // sets the authentication database required by mongo 3
]
],
```
......@@ -133,12 +133,9 @@ You can connect to multiple servers or replica sets with the following configura
'host' => ['server1', 'server2'],
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', ''),
'options' => [
'replicaSet' => 'replicaSetName',
'db' => 'admin', // sets the authentication database required by mongo 3
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
]
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'options' => ['replicaSet' => 'replicaSetName']
],
```
......
......@@ -136,6 +136,13 @@ class Connection extends \Illuminate\Database\Connection
$driverOptions = $config['driver_options'];
}
if (!isset($options['username'])){
$options['username'] = isset($config['username']) ? $config['username'] : '';
}
if (!isset($options['password'])){
$options['password'] = isset($config['password']) ? $config['password'] : '';
}
return new Client($dsn, $options, $driverOptions);
}
......
......@@ -209,7 +209,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
* @param array $parameters
* @return Blueprint
*/
protected function addColumn($type, $name, array $parameters = [])
public function addColumn($type, $name, array $parameters = [])
{
$this->fluent($name);
......
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