Skip to content

Instantly share code, notes, and snippets.

@michaeldyrynda
Created April 9, 2018 04:24
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save michaeldyrynda/381024012249661a52fed7351c3e39a5 to your computer and use it in GitHub Desktop.
Save michaeldyrynda/381024012249661a52fed7351c3e39a5 to your computer and use it in GitHub Desktop.
<?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