diff --git a/README.md b/README.md index 9568ed73..24134d93 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,13 @@ return [ * used by the Activity model shipped with this package. */ 'table_name' => 'activity_log', + + /* + * This is the database connection that will be used by the migration and + * the Activity model shipped with this package. In case it's not set + * Laravel database.default will be used instead. + */ + 'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), ]; ``` diff --git a/config/activitylog.php b/config/activitylog.php index 13b78452..a6558ecb 100644 --- a/config/activitylog.php +++ b/config/activitylog.php @@ -45,7 +45,8 @@ /* * This is the database connection that will be used by the migration and - * the Activity model shipped with this package. + * the Activity model shipped with this package. In case it's not set + * Laravel database.default will be used instead. */ - 'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION', env('DB_CONNECTION', 'mysql')), + 'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), ]; diff --git a/tests/CustomDatabaseConnectionActivityModelTest.php b/tests/CustomDatabaseConnectionActivityModelTest.php index dca0b363..2494bd9e 100644 --- a/tests/CustomDatabaseConnectionActivityModelTest.php +++ b/tests/CustomDatabaseConnectionActivityModelTest.php @@ -26,6 +26,16 @@ public function it_uses_a_custom_database_connection() $this->assertEquals($model->getConnectionName(), 'custom_sqlite'); } + /** @test */ + public function it_uses_the_default_database_connection_when_the_one_from_configuration_is_null() + { + $this->app['config']->set('activitylog.database_connection', null); + + $model = new Activity(); + + $this->assertInstanceOf('Illuminate\Database\SQLiteConnection', $model->getConnection()); + } + /** @test */ public function it_uses_the_database_connection_from_model() {