Last active
February 12, 2019 15:13
-
-
Save thmsbkkr/43b55445f2abe3b6143fd6525d1733e7 to your computer and use it in GitHub Desktop.
Address Filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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