I'm deploying my application to my production environment and it's not working as expected. I've narrowed the issue down to one line inside this loop in my controller;

```
foreach($temp_table_data as $a_payment) {
  //array_push($payments, $a_payment->payment); //big collection object
  array_push($payments, $a_payment->payment->first()->attributesToArray()); //smaller object
}

```

The error I get is `call to a member function attributesToArray() on a non object`. This seems crazy to be because - as the old saying goes - it works fine on my machine.

My dev. environment is Ubuntu trusty64 on PHP 5.5.21 and my production is RedHat Linux PHP 5.5.11. I thought these differences were very minor (maybe I'm wrong?).

If I do a `print_r($temp_table_data()` then I get a big collection returned. The same on both servers. So at some point it just stops liking either `payment` (that's a method) or `first()`

Here is partial of my TempTable.php Model with the payment method;

```
public function payment(){
    return $this->hasMany('App\Models\Payment', 'Vendor ZIP', 'postcode');
}

```

And my `Payment.php` model (part of it);

```
class Payment extends Model {

protected $table = 'headquarters_data';

public function tempTable()
{
    return $this->belongsTo('App\Models\TempTable', 'postcode', 'Vendor ZIP');
}

```