PHP code example of jie-anthony / eloquent-filter-in-hyperf
1. Go to this page and download the library: Download jie-anthony/eloquent-filter-in-hyperf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jie-anthony / eloquent-filter-in-hyperf example snippets
declare (strict_types=1);
namespace App\ModelFilters;
use JieAnthony\EloquentFilter\ModelFilter;
class UserFilter extends ModelFilter
{
public function name($name)
{
return $this->where('name', 'LIKE', "$name%");
}
public function age($age)
{
return $this->where('age', $age);
}
}
declare (strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
use JieAnthony\EloquentFilter\Filterable;
class User extends Model
{
use Filterable;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users';
public function modelFilter()
{
return $this->provideFilter(\App\ModelFilters\UserFilter::class);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.