Skip to content

Commit 2ecd83a

Browse files
committed
Merge branch 'thyseus-make-db-connection-configurable' into develop
2 parents 844b11a + 4f5d647 commit 2ecd83a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ return [
4646
// You can change this if the database keys get too long for your driver
4747
'table_name' => 'authentication_log',
4848

49+
// The database connection where the authentication_log table resides. Leave empty to use the default
50+
'db_connection' => null,
51+
4952
'notifications' => [
5053
'new-device' => [
5154
// Send the NewDevice notification

config/authentication-log.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// You can change this if the database keys get too long for your driver
66
'table_name' => 'authentication_log',
77

8+
// The database connection where the authentication_log table resides. Leave empty to use the default
9+
'db_connection' => null,
10+
811
'notifications' => [
912
'new-device' => [
1013
// Send the NewDevice notification

src/Models/AuthenticationLog.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AuthenticationLog extends Model
1010
public $timestamps = false;
1111

1212
protected $table = 'authentication_log';
13-
13+
1414
protected $fillable = [
1515
'ip_address',
1616
'user_agent',
@@ -32,6 +32,15 @@ class AuthenticationLog extends Model
3232
'logout_at',
3333
];
3434

35+
public function __construct(array $attributes = [])
36+
{
37+
if (! isset($this->connection)) {
38+
$this->setConnection(config('authentication-log.db_connection'));
39+
}
40+
41+
parent::__construct($attributes);
42+
}
43+
3544
public function getTable()
3645
{
3746
return config('authentication-log.table_name', parent::getTable());

0 commit comments

Comments
 (0)