2013-07-31 23 views
0

我有一些代碼在我的本地機器(WAMP,PHP 5.4.3)上正常工作,但不在生產服務器上(CentOS,PHP 5.4.11)我不明白爲什麼,問題的代碼行是:Laravel live服務器無法正常加載

$sharedList = SharedList::with('itemList') 
          ->where('unique_url', '=', $uniqueURL) 
          ->first(); 

如果我刪除了與()預先加載,然後這個運行沒有問題,如果我不這麼做(我不需要我的本地計算機上),然後我得到這樣的:

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) 

從SharedList模型的相關關係的信息是:

class SharedList extends Ardent { 

public function itemList() 
{ 
    return $this->belongsTo('ItemList', 'list_id'); 
} 

我不知道這是否是大寫問題,在with()方法中,我嘗試了ItemList,itemlist和itemList。

這可能是一個熱心的問題,但我試圖用extend Eloquent代替extend Ardent無濟於事。

回答

0

您的with('itemList')是正確的,因爲它應該是建立關係的函數的名稱。我有一種感覺,問題可能是隨後的where子句出現。嘗試懶惰渴望加載。

$sharedList = SharedList::where('unique_url',$uniqueURL)->get(); 
$sharedList->load('itemList'); 
+0

嗨,這拋出了完全相同的錯誤,我想這是關係建立在某種程度上 –