Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
issue #23 refactor if statement for fixing issue between linux and wi…
…ndows

The cause of this problem lies also in different phpversions
  • Loading branch information
arnaud committed Oct 30, 2018
commit 064f5bae99c015249fcf62de714612887e2b090e
21 changes: 20 additions & 1 deletion src/Traits/HandlesRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getRelationships($model): array//TODO: Skipt relaties die geen r
if (!$returnType) {
continue;
}
if (in_array(pathinfo($returnType)['basename'], $this->relationshipTypes)) {
if ($this->isRelationshipReturntype($returnType)) {
$relations[] = $method->getName();
}
}
Expand Down Expand Up @@ -164,4 +164,23 @@ protected function getNestedRelation($include): array

return [$nestedInclude, $include];
}

/**
* @param $returnType
* @return bool
*/
protected function isRelationshipReturntype($returnType): bool
{
/**
* compatibility php7.0 & php7.1+
*/
$returnTypeClassname = null;
if(is_callable([$returnType, 'getName'])) {
$returnTypeClassname = $returnType->getName();
} else {
$returnTypeClassname = (string) $returnType;
}

return in_array($returnTypeClassname, $this->relationshipTypes);
}
}