mardi 4 avril 2017

Query returning collection of arrays instead of collection of models

I created a website with homestead using Laravel 5.3.31 and PHP 7.1.2. I have the same exact site hosted on a remote server, also using Laravel 5.3.31 and PHP 7.1.3.

I have the following code in one of my views:

$users = \DB::table('users')->get();
dd($users);

On the homestead site, I get the following result:

Collection {#327 ▼
  #items: array:1 [▼
    0 => {#334 ▼
      +"uid": 1
      +"user_name": "test"
      +"email": "test@gmail.com"
      +"password": "somehashcode"
      +"status": "active"
      +"remember_token":  "priEYh5ewdq2IlwCwOyNc8x1w0L1zNdWHV1wLznaBfhxoWex4rDvb8lijc5T"
      +"created_at": "2017-03-20 18:30:46"
      +"updated_at": "2017-03-28 17:12:49"
    }
  ]
}

On my remote server, on the other hand, I get this result instead:

Collection {#320 ▼
  #items: array:1 [▼
    0 => array:16 [▼
      "uid" => 1
      0 => 1
      "user_name" => "test"
      1 => "test"
      "email" => "test@gmail.com"
      2 => "test@gmail.com"
      "password" => "somehashcode"
      3 => "somehashcode"
      "status" => "active"
      4 => "active"
      "remember_token" => "WnKr77qKbgRwekZEdc9DhjLncYre5h7WvZrW7OkpOG8FZJuNFxC0CqRA5lEK"
      5 => "WnKr77qKbgRwekZEdc9DhjLncYre5h7WvZrW7OkpOG8FZJuNFxC0CqRA5lEK"
      "created_at" => null
  6 => null
  "updated_at" => "2017-04-03 19:49:50"
  7 => "2017-04-03 19:49:50"
]

] }

Because of this, I am not able to do $user->uid on the remote server and I cannot understand what possibly could be the culprit for this. Any ideas? Could this be a PHP issue?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire