ResponseConverter.php 572 B

1234567891011121314151617
  1. <?php
  2. namespace App\Helpers;
  3. class ResponseConverter
  4. {
  5. public static function joinFor($hdPage, $bdPage, $toName = 'HId', $fromName = 'Id', $pageName = 'BdPage'): array
  6. {
  7. return collect($hdPage)->map(function ($hd) use ($bdPage, $toName, $fromName, $pageName) {
  8. $filterPage = collect($bdPage)->filter(function ($bd) use ($hd, $toName, $fromName) {
  9. return $hd[$fromName] === (int)$bd[$toName];
  10. })->values()->toArray();
  11. return array_merge($hd, [$pageName => $filterPage]);
  12. })->toArray();
  13. }
  14. }