Skip to content

Commit d0d4c14

Browse files
authored
allow a different database connection for the Translation model (#426)
1 parent b21c18a commit d0d4c14

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

config/translation-manager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@
6666
'$trans.get',
6767
],
6868

69+
/**
70+
* Database connection name to allow for different db connection for the translations table.
71+
*/
72+
'db_connection' => env('TRANSLATION_MANAGER_DB_CONNECTION', null),
73+
6974
];

src/Models/Translation.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,18 @@ public function scopeSelectDistinctGroup($query)
5252
return $query->select(DB::raw($select));
5353
}
5454

55+
/**
56+
* Get the current connection name for the model.
57+
*
58+
* @return string|null
59+
*/
60+
public function getConnectionName()
61+
{
62+
if ($connection = config('translation-manager.db_connection')){
63+
return $connection;
64+
}
65+
66+
return parent::getConnectionName();
67+
}
68+
5569
}

0 commit comments

Comments
 (0)