Skip to content

Instantly share code, notes, and snippets.

@shrestharikesh
Created September 18, 2019 02:47
Show Gist options
  • Save shrestharikesh/fc4df845f76caff2874f6b437d0fce69 to your computer and use it in GitHub Desktop.
Save shrestharikesh/fc4df845f76caff2874f6b437d0fce69 to your computer and use it in GitHub Desktop.
Helpful Laravel Custom Helper Functions
<?php
/**
* case insensetive filter for collection
*/
if (!function_exists('collectionFilter')) {
function collectionFilter($collection,$attribute,$value)
{
return $collection->filter(function ($item) use ($attribute, $value) {
return strtolower($item[$attribute]) == strtolower($value);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment