Skip to content

Instantly share code, notes, and snippets.

@thmsbkkr
Last active February 12, 2019 15:13
Show Gist options
  • Save thmsbkkr/43b55445f2abe3b6143fd6525d1733e7 to your computer and use it in GitHub Desktop.
Save thmsbkkr/43b55445f2abe3b6143fd6525d1733e7 to your computer and use it in GitHub Desktop.
Address Filtering
<?php
/**
* Filter the model using value.
*
* @param Builder $builder
* @param $value
* @return mixed
*/
public function filter(Builder $builder, $value, $direction)
{
return $builder->whereHas('address', function ($builder) use ($value, $direction) {
$builder
->where('street', 'like', '%' . $value . '%')
->orderBy('street', $direction);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment