2017-01-27 19 views
0

私はlaravel 5.3のような関係を得ていたと罰金働いていた:5.3からLaravel 5.4:エラーgetOtherKey()

//execute the relation of the given model 
$data = $model->{$info["relation"]}(); 

// get the type of the relation 
$class = get_class($data); 
$dataType = explode("\\", $class); 
$relationType = end($dataType); 

$options["columns"][$key]["relationType"] = $relationType; 

// if its a simple belongs-to statement 
if($relationType == "BelongsTo") { 

    // get all belongs-to query info 
    $otherTable = $data->getRelated()->getTable(); 
    $foreignKey = $data->getQualifiedForeignKey(); 
    $otherKey = $data->getOtherKey(); 

    // manually join using it 
    $retrievedRecords->leftJoin($otherTable . ' as ' . $info["relation"], $info["relation"] . '.' . $otherKey, '=', $foreignKey); 

} else if($relationType == "HasMany" || $relationType == "HasOne") { 

    // get all has-many query info 
    $otherTable = $data->getRelated()->getTable(); 
    $foreignKey = $data->getPlainForeignKey(); 
    $parentKey = $data->getQualifiedParentKeyName(); 

    // manually join using it 
    $retrievedRecords->leftJoin($otherTable . ' as ' . $info["relation"], $info["relation"] . '.' . $foreignKey, '=', $parentKey); 

} 

は、今私は、新鮮なlaravel 5.4をダウンロードし、それは私にエラーを与える:

Call to undefined method Illuminate\Database\Query\Builder::getOtherKey()

上記のコードにgetOtherKey()があるので、if()セクションにあります。

これに代わる方法はありますか?

答えて

1

getOtherKeyメソッドの名前がgetOwnerKeyに変更されました。だから、あなたはオーナーの鍵を得ることができる:

$ownerKey = $data->getOwnerKey(); 
関連する問題