Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Laravelista's avatar

Duplicated properties on every retrieved model

This is a weird one, every model retrieved from the database has its keyed properties, but also a duplicated property keyed by a numeric index.

Tinker output below:

` use App\V1\Models\User;

$user = User::find(11);

App\V1\Models\User {#3129

 id: 11,

 0: 11,

 first_name: "test",

 1: "test",

 last_name: "tester",

 2: "tester",

 username: "testo",

 3: "testo",

 email: "[email protected]",

 4: "[email protected]",`

Recent changes to the application arquitecture included the separation of the users table into a dedicated database of its own, for this purpose another connection was added to config/database.php and set on the User model.

But the duplicated properties thing happens to every model.

0 likes
1 reply
Laravelista's avatar

Solved, it was the fetch config @config/database.php, it had to be set to PDO::FETCH_CLASS

1 like

Please or to participate in this conversation.