저는 cakePHP를 처음 사용하므로 초보자 용 질문 일 수 있습니다.Friendsofcake의 CakePHP 검색 플러그인을 설치할 수 없습니다.
내가 필드 이메일 (VARCHAR)과 에 의해 내 사용자를 검색 할 수 QANT 위의 링크에서 추가 정보를 사용 Friendsofcake (https://github.com/FriendsOfCake/search)
에 의해 CakePHP를위한 검색 플러그인을 설치하려고 RG (정수).
하지만 방문하려고 시도 할 때 시스템이이 텍스트 끝 부분에 오류를 표시합니다. 검색 플러그인이 내 bootstrap.php에로드 된 경우에도 findParams 메서드가 유효하지 않은 것 같습니다.
나는 다음과 같은 UsersTable.php 및 UsersController.php 있습니다
UsersTable :
use Search\Manager;
class UsersTable extends Cake\ORM\Table {
public function initialize(array $config)
{
parent::initialize();
// Add the behaviour to your table
$this->addBehavior('Search.Search');
}
// Configure how you want the search plugin to work with this table class
public function searchConfiguration()
{
$search = new Manager($this);
$search
->value('email', [
'field' => $this->aliasField('email'),
])
// Here we will alias the 'q' query param to search the `Users.email`
// field and the `Users.rg` field, using a LIKE match, with `%`
// both before and after.
->like('q', [
'before' => true,
'after' => true,
'field' => [$this->aliasField('email'), $this->aliasField('rg')]
])
->callback('foo', [
'callback' => function ($query, $args, $manager) {
// Modify $query as required
}
]);
return $search;
}
}
UsersController :
namespace App\Controller;
class UsersController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadComponent('Search.Prg', [
'actions' => ['index']
]);
}
public function login() {
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error('Your username or password is incorrect.');
}
}
public function logout() {
$this->Flash->success('You are now logged out.');
return $this->redirect($this->Auth->logout());
}
public function index()
{
$query = $this->Users
// Use the plugins 'search' custom finder and pass in the
// processed query params
->find('search', $this->Users->filterParams($this->request->query))
// You can add extra things to the query if you need to
->contain(['rg'])
->where(['email IS NOT' => null]);
$this->set('articles', $this->paginate($query));
}
}
지금은 오류가 점점 오전 :
을Unknown method "filterParams" BadMethodCallException
⟩ Cake\ORM\Table->__call APP/Controller\UsersController.php, line 42 ⟩ App\Controller\UsersController->index [internal function] ⟩ call_user_func_array ROOT\vendor\friendsofcake\crud\src\Controller\ControllerTrait.php, line 51 ⟩ App\Controller\AppController->invokeAction CORE\src\Routing\Dispatcher.php, line 114 ⟩ Cake\Routing\Dispatcher->_invoke CORE\src\Routing\Dispatcher.php, line 87 ⟩ Cake\Routing\Dispatcher->dispatch ROOT\webroot\index.php, line 36