Rapid Search for Codeigniter 4 framework
composer require aselsan/search
use SearchTrait
in your model, as follows:
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
use SearchTrait; //Add this
// Optional properties
protected $search = ['first_name', 'last_name'];
Somewhere in your controller
$keyword = "jhon doe";
// Match any fields
model(UserModel::class)->search($keyword)->paginate();
// Match all fields
model(UserModel::class)->search($keyword, true)->paginate();
This project is licensed under the MIT License - see the LICENSE file for details.