simtecsystem/cakephp-filter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simtecsystem/cakephp-filter

Composer 安装命令:

composer require simtecsystem/cakephp-filter

包简介

Filter plugin for CakePHP >3.6

README 文档

README

Software License Total Downloads Latest Stable Version Build Status Coverage Status

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require simtecsystem/cakephp-filter

Load the plugin

Add following to your config/bootstrap.php

Plugin::load('BRFilter');

Usage

Controller class

public function index()
{
		$this->loadComponent('BRFilter.Filter');
		
		// add filter and options
		$this->Filter->addFilter([
					'filter_id' => ['field' => 'Posts.id', 'operator'=>'='],
					'filter_title' => ['field' => 'Posts.title', 'operator' => 'LIKE', 'explode' => 'true'],
					'filter_category_id' => ['field'=> 'Posts.category_id', 'operator' => 'IN' ] 
		]);
		
		// get conditions
		$conditions = $this->Filter->getConditions(['session'=>'filter']);
		
		// set url for pagination
    	$this->set('url', $this->Filter->getUrl());
    	
    	// apply conditions to pagination
    	$this->paginate['conditions']	= $conditions;
    	
    	// get pagination 
    	$this->set('posts', $this->paginate($this->Posts));
    	
    	// ...
}

Template views

You have to add a form to your index.ctp, corresponding with the alias of your filter configuration.

	echo $this->Form->create();
    
   	// Match with the filter configuration in your controller 
    echo $this->Form->input('filter_id', ['type' => 'text']);
    echo $this->Form->input('filter_title', ['type' => 'text']);
    echo $this->Form->input('filter_category_id', ['options'=>[ /* ... */ ], 'multiple'=>'multiple' ]);
    
	echo $this->Form->button('Filter', ['type' => 'submit']);
	echo $this->Form->end();

Filter options

The following options are supported:

  • field (string) The name of the field to use for searching.
  • operator (string) The operator used for searching.
  • explode (boolean) Used only with operator LIKE and ILIKE to explode the string query.

Operators

The following options are supported:

  • =
  • >
  • <
  • >=
  • <=
  • LIKE
  • ILIKE
  • IN

Persisting query (session)

All query strings are persisted using sessions. Make sure to load the Session component.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固