I've got some code that has been working fine on my local machine (WAMP, PHP 5.4.3) but not on a production server (CentOS, PHP 5.4.11) and I can't see why, the offending line of code is:
$sharedList = SharedList::with('itemList')
->where('unique_url', '=', $uniqueURL)
->first();
if I remove the with() eager loading then this runs without issue, if I don't (and I don't need to on my local machine) then I get this:
Argument 2 passed to Illuminate\Database\Eloquent\Relations\BelongsTo::match()
must be an instance of Illuminate\Database\Eloquent\Collection, instance of
ItemList given, called in /home/mgc/public_html/test/vendor/laravel/framework
/src/Illuminate/Database/Eloquent/Builder.php on line 474 and defined
/home/site/public_html/test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
line 154: public function match(array $models, Collection $results, $relation)
The relevant relationship info from the SharedList model is:
class SharedList extends Ardent {
public function itemList()
{
return $this->belongsTo('ItemList', 'list_id');
}
I don't know if this is a capitalisation issue, in the with() method I have tried ItemList, itemlist and itemList.
It could be an Ardent issue, but I have tried replacing extend Ardent
with extend Eloquent
to no avail.