1. Go to this page and download the library: Download syhcode/tp-model-filter 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/ */
syhcode / tp-model-filter example snippets
declare (strict_types = 1);
namespace app\model;
use think\Model;
use tpModelFilter\Filterable;
/**
* @mixin think\Model
*/
class Users extends Model
{
use Filterable;
}
namespace app\modelFilter;
use tpModelFilter\ModelFilter;
class UsersFilter extends ModelFilter {
public function name($value){
return $this->whereLike("name","%".$value."%");
}
public function nickName($value){
return $this->where("password",$value);
}
}
namespace app\controller;
use app\BaseController;
use app\model\Users;
use app\Request;
class Index extends BaseController
{
public function index(Request $request,Users $users)
{
return $users->filter($request->request())->select();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.