Skip to content

Commit

Permalink
feat(helpers): remove inIds method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Feb 5, 2024
1 parent 063bca1 commit ae4b614
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/Helpers/helpers.php
Expand Up @@ -17,24 +17,3 @@ function uncamelize($word, string $splitter = ' ', bool $uppercase = true): arra
return $uppercase ? ucwords($word) : $word;
}
}

if (!function_exists('inIds')) {
/**
* Check if the given id is in the given model collection by comparing hashed ids.
*
* @param Collection|array $ids either a collection of models or an array of unhashed ids
*/
function inIds(string $hashedId, Collection|array $ids): bool
{
$hashService = new class() extends Apiato\Core\Abstracts\Models\Model {
use Apiato\Core\Traits\HashIdTrait;
};

$id = $hashService->decode($hashedId);
if ($ids instanceof Collection) {
return $ids->contains('id', $id);
}

return in_array($hashService->decode($hashedId), $ids, true);
}
}

0 comments on commit ae4b614

Please sign in to comment.