Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
return [
'driver' => env('CONNECTION_DB_DRIVER', 'mysql'),
'host' => env('CONNECTION_DB_HOST', env('DB_HOST', '127.0.0.1')),
'port' => env('CONNECTION_DB_PORT', env('DB_PORT', '3306')),
'database' => env('CONNECTION_DB_DATABASE', env('DB_DATABASE', 'forge')),
'username' => env('CONNECTION_DB_USERNAME', env('DB_USERNAME', 'forge')),
'password' => env('CONNECTION_DB_PASSWORD', env('DB_PASSWORD', '')),
'unix_socket' => env('CONNECTION_DB_SOCKET', env('DB_SOCKET', '')),
'charset' => 'latin1',
'collation' => 'latin1_swedish_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
];
<?php
namespace Mithrandir\Providers;
class ConnectionServiceProvider extends MithrandirServiceProvider
{
protected $connectionName = 'connection';
}
<?php
namespace Mithrandir\Providers;
use Illuminate\Support\ServiceProvider;
class MithrandirServiceProvider extends ServiceProvider
{
protected $connectionName;
public function boot()
{
$this->loadMigrationsFrom($this->migrationPath());
}
public function register()
{
$this->mergeConfigFrom($this->configPath(), $this->configKey());
}
protected function migrationPath()
{
return dirname(__FILE__)."/../../database/migrations/{$this->connectionName}";
}
protected function configPath()
{
return dirname(__FILE__)."/../../config/{$this->connectionName}.php";
}
protected function configKey($prefix = 'database.connections')
{
return "{$prefix}.{$this->connectionName}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment