Skip to content

Commit

Permalink
Simplify with crossJoin
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSilber committed Feb 21, 2022
1 parent 91b32a2 commit fcbb176
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Conductors/AssignsRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ protected function getExistingAttachRecords($roleIds, $morphType, $authorityIds)
*/
protected function buildAttachRecords($roleIds, $morphType, $authorityIds)
{
return $roleIds->map(function ($roleId) use ($morphType, $authorityIds) {
return $authorityIds->map(function ($authorityId) use ($roleId, $morphType) {
return $roleIds
->crossJoin($authorityIds)
->mapSpread(function ($roleId, $authorityId) use ($morphType) {
return Models::scope()->getAttachAttributes() + [
'role_id' => $roleId,
'entity_id' => $authorityId,
'entity_type' => $morphType,
];
});
})->collapse();
}

/**
Expand Down

0 comments on commit fcbb176

Please sign in to comment.