diff --git a/config/activitylog.php b/config/activitylog.php index 5f6afcfa..f1262f54 100644 --- a/config/activitylog.php +++ b/config/activitylog.php @@ -41,7 +41,7 @@ * This is the name of the table that will be created by the migration and * used by the Activity model shipped with this package. */ - 'table_name' => 'activity_log', + 'table_name' => env('ACTIVITY_LOGGER_TABLE_NAME', 'activity_log'), /* * This is the database connection that will be used by the migration and diff --git a/docs/installation-and-setup.md b/docs/installation-and-setup.md index 52e58499..07168fab 100644 --- a/docs/installation-and-setup.md +++ b/docs/installation-and-setup.md @@ -57,7 +57,7 @@ return [ /* * You can specify an auth driver here that gets user models. - * If this is null we'll use the default Laravel auth driver. + * If this is null we'll use the current Laravel auth driver. */ 'default_auth_driver' => null, @@ -68,7 +68,7 @@ return [ /* * This model will be used to log activity. - * It should be implements the Spatie\Activitylog\Contracts\Activity interface + * It should implement the Spatie\Activitylog\Contracts\Activity interface * and extend Illuminate\Database\Eloquent\Model. */ 'activity_model' => \Spatie\Activitylog\Models\Activity::class, @@ -77,6 +77,13 @@ return [ * This is the name of the table that will be created by the migration and * used by the Activity model shipped with this package. */ - 'table_name' => 'activity_log', + 'table_name' => env('ACTIVITY_LOGGER_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's database.default will be used instead. + */ + 'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), ]; ``` diff --git a/tests/TestCase.php b/tests/TestCase.php index f631a110..17348a98 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,6 +32,7 @@ protected function getPackageProviders($app) public function getEnvironmentSetUp($app) { + config()->set('activitylog.table_name', 'activity_log'); config()->set('activitylog.database_connection', 'sqlite'); config()->set('database.default', 'sqlite'); config()->set('database.connections.sqlite', [ @@ -45,7 +46,7 @@ public function getEnvironmentSetUp($app) )); } - protected function setUpDatabase() + protected function setUpDatabase(): void { $this->migrateActivityLogTable(); @@ -53,7 +54,7 @@ protected function setUpDatabase() $this->seedModels(Article::class, User::class); } - protected function migrateActivityLogTable() + protected function migrateActivityLogTable(): void { require_once __DIR__.'/../database/migrations/create_activity_log_table.php.stub'; require_once __DIR__.'/../database/migrations/add_event_column_to_activity_log_table.php.stub'; @@ -64,7 +65,7 @@ protected function migrateActivityLogTable() (new AddBatchUuidColumnToActivityLogTable())->up(); } - protected function createTables(...$tableNames) + protected function createTables(...$tableNames): void { collect($tableNames)->each(function (string $tableName) { Schema::create($tableName, function (Blueprint $table) use ($tableName) { @@ -86,7 +87,7 @@ protected function createTables(...$tableNames) }); } - protected function seedModels(...$modelClasses) + protected function seedModels(...$modelClasses): void { collect($modelClasses)->each(function (string $modelClass) { foreach (range(1, 0) as $index) {