Skip to content

Instantly share code, notes, and snippets.

@mohammad-fouladgar
Last active July 19, 2019 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohammad-fouladgar/d9ea28c6e4088f450a1eef6b71b0f94c to your computer and use it in GitHub Desktop.
Save mohammad-fouladgar/d9ea28c6e4088f450a1eef6b71b0f94c to your computer and use it in GitHub Desktop.
Defining a filter in Eloquent-Builder Package
<?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