Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations Tests and database tweaks #1660

Merged
merged 8 commits into from
Jan 14, 2019
Prev Previous commit
Next Next commit
DRYed up the forge connection command.
  • Loading branch information
lonnieezell committed Jan 6, 2019
commit d8482ab8f362f10dcde348f6f32d19a4794a7ce9
39 changes: 1 addition & 38 deletions system/Database/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,44 +141,7 @@ public static function getConnections()
*/
public static function forge($group = null)
{
// Allow custom connections to be sent in
if (is_array($group))
{
$config = $group;
$group = 'custom-' . md5(json_encode($config));
}
else
{
$config = config('Database');
}

static::ensureFactory();

if (empty($group))
{
$group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;
}

if (is_string($group) && ! isset($config->$group) && ! is_array($config))
{
throw new \InvalidArgumentException($group . ' is not a valid database connection group.');
}

if (! isset(static::$instances[$group]))
{
if (is_array($config))
{
$db = static::connect($config);
}
else
{
$db = static::connect($group);
}
}
else
{
$db = static::$instances[$group];
}
$db = static::connect($group);

return static::$factory->loadForge($db);
}
Expand Down