Skip to content

Commit 24aa659

Browse files
committed
Feat: laravel 6 upgrade bug fix getForeignKeyName, getQualifiedForeignKeyName, and getOwnerKeyName
1 parent 2d36b1f commit 24aa659

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/ApiController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ protected function addIncludes()
435435
// We need to select foreign key so that Laravel can match to which records these
436436
// need to be attached
437437
if ($q instanceof BelongsTo) {
438-
$fields[] = $q->getOwnerKey();
438+
$fields[] = $q->getOwnerKeyName();
439439

440440
if (strpos($key, ".") !== false) {
441441
$parts = explode(".", $key);

src/ApiModel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function fill(array $attributes = [])
265265
}
266266
}
267267

268-
$relationKey = $relation->getForeignKey();
268+
$relationKey = $relation->getForeignKeyName();
269269

270270
$this->setAttribute($relationKey, ($attribute === null) ? null : $model->getKey());
271271
}
@@ -302,7 +302,7 @@ public function save(array $options = [])
302302
}
303303
}
304304

305-
$relationKey = $relation->getForeignKey();
305+
$relationKey = $relation->getForeignKeyName();
306306

307307
$this->setAttribute($relationKey, ($relationAttribute === null) ? null : $model->getKey());
308308

@@ -395,4 +395,4 @@ public function save(array $options = [])
395395
}
396396
}
397397
}
398-
}
398+
}

src/RequestParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ private function parseFields($fields)
426426
$fieldParts = explode(".", $fieldName);
427427

428428
if ($relation instanceof BelongsTo) {
429-
$singular = $relation->getForeignKey();
429+
$singular = $relation->getForeignKeyName();
430430
}
431431
else if ($relation instanceof HasOne || $relation instanceof HasMany) {
432432
$singular = $relation->getForeignKeyName();
@@ -475,7 +475,7 @@ private function parseFields($fields)
475475
$keyField = explode(".", $relation->getQualifiedParentKeyName())[1];
476476
}
477477
else if ($relation instanceof BelongsTo) {
478-
$keyField = explode(".", $relation->getQualifiedForeignKey())[1];
478+
$keyField = explode(".", $relation->getQualifiedForeignKeyName())[1];
479479
}
480480

481481
if (isset($keyField) && !in_array($keyField, $this->fields)) {
@@ -507,4 +507,4 @@ private function loadTableName()
507507
$this->table = call_user_func($this->model."::getTableName");
508508
}
509509

510-
}
510+
}

0 commit comments

Comments
 (0)