PHP code example of goletter / hyperf-modelfilter
1. Go to this page and download the library: Download goletter/hyperf-modelfilter 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/ */
goletter / hyperf-modelfilter example snippets
安装最新版
composer lters
在模型中使用trait
use Goletter\ModelFilter\Filterable;
class Tag extends Model
{
use Filterable;
}
创建filter类
在app/Model/Filters中创建模型名+Filter的文件
use Goletter\ModelFilter\ModelFilter;
class TagFilter extends ModelFilter
{
public function id($value)
{
return $this->where('id',$value);
}
public function name($value)
{
return $this->where('name','like',$value.'%');
}
public function order($value)
{
return $this->where('order','>=',$value);
}
}