Commit e1814fc
Ronald A Richardson
fix: correct config key typo and pin Invite to production DB via getConnectionName()
Reverts the two overcorrecting commits (561d3cd, 3865ec7) and replaces
them with the minimal, correct changes:
## 1. Config key typo fix (Model.php, Setting.php)
The base Model constructor and Setting constructor both used:
$this->connection = config('fleetbase.db.connection');
The correct key is 'fleetbase.connection.db'. The wrong key returned null,
which caused $this->connection to be set to null on every instantiation,
making all models fall back to config('database.default'). In sandbox mode
that is 'sandbox', so models that explicitly declared $connection = 'mysql'
(Invite, Setting, User, Company, etc.) were silently overwritten.
Fixed to: config('fleetbase.connection.db', 'mysql')
The constructor is intentionally kept — it is the correct place to resolve
the configured production connection name for models that do not declare
their own $connection.
## 2. Invite::getConnectionName() override (Invite.php)
Invites must always be stored in and read from the production database,
regardless of sandbox mode. The $connection property alone is insufficient
because the base Model constructor overwrites it at instantiation time.
Overriding getConnectionName() is the Laravel-idiomatic way to enforce a
hard connection binding at the model level — it is called by Eloquent for
every query and cannot be overridden by runtime config changes.1 parent 3865ec7 commit e1814fc
3 files changed
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
41 | 60 | | |
42 | 61 | | |
43 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
33 | 47 | | |
34 | 48 | | |
35 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
23 | 37 | | |
24 | 38 | | |
25 | 39 | | |
| |||
0 commit comments