Last active
July 19, 2019 15:11
-
-
Save mohammad-fouladgar/d9ea28c6e4088f450a1eef6b71b0f94c to your computer and use it in GitHub Desktop.
Defining a filter in Eloquent-Builder Package
This file contains 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 | |
namespace App\EloquentFilters\User; | |
use Fouladgar\EloquentBuilder\Support\Foundation\Contracts\Filter; | |
use Illuminate\Database\Eloquent\Builder; | |
class AgeMoreThanFilter implements Filter | |
{ | |
/** | |
* Apply the age condition to the query. | |
* | |
* @param Builder $builder | |
* @param mixed $value | |
* | |
* @return Builder | |
*/ | |
public function apply(Builder $builder, $value): Builder | |
{ | |
return $builder->where('age', '>', $value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment