Skip to content

Commit

Permalink
Cast to int when fetching BelongsToMany values
Browse files Browse the repository at this point in the history
  • Loading branch information
endihunter authored Jul 24, 2018
1 parent 7964bc0 commit 10a6df9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Traits/LoopsOverRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ protected function fetchRelationValue($eloquent, $name, array $relations = [], $

// Treat BelongsToMany form relation as array of values.
if ($object instanceof BelongsToMany) {
return \DB::table($object->getTable())
->where($this->getQualifiedForeignKeyName($object), $orig->getKey())
->pluck($this->getQualifiedRelatedKeyName($object))
->toArray();
return array_map(
'intval',
\DB::table($object->getTable())
->where($this->getQualifiedForeignKeyName($object), $orig->getKey())
->pluck($this->getQualifiedRelatedKeyName($object))
->toArray()
);
}

$object = $object->getResults();
Expand Down

0 comments on commit 10a6df9

Please sign in to comment.