2014-01-06 2 views
0

형 hasMany의()를 오프셋 오류 :Laravel은 불법는 내 코드가

Illegal offset type 
Illuminate/Database/Eloquent/Relations/HasOneOrMany.php 

    $foreign = $this->getPlainForeignKey(); 

    // First we will create a dictionary of models keyed by the foreign key of the 
    // relationship as this will allow us to quickly access all of the related 
    // models without having to do nested looping which will be quite slow. 
    foreach ($results as $result) 
    { 
     $dictionary[$result->{$foreign}][] = $result; 
    } 

갱신

.sub_group을 제거하면 오류를 반환하지 않습니다.

// works 
$user = User::where('uid', $user_id)->with('groups')->firstOrFail(); 

답변

0

그 관계에 대한 확신이 있습니까?

hasMany이어야하며 belongsTo는 그룹 모델

이어야합니다.