Welcome Guest, Not a member yet? Register   Sign In
Pagination don't work
#1

(This post was last modified: 11-15-2019, 02:19 AM by dimonisse.)

Hi all!
I'm trying to configure pagination for my project, I do everything according to the documentation, but I get an error. With version 3, there were no such problems ((

PHP Code:
lass User extends Controller{
    
    
public $model;
    public $locale;

    function __construct()
    {
        $this->locale  =  service('request')->getLocale();
        $this->model = new UserModel();
    

    /*
     * Listing of users
     */
    function index()
    {

        $data = [
            'users'=>$this->model->get_all_users()->paginate(10),
            'pager'=>$this->model->get_all_users()->pager,
            'locale' => $this->locale
        
];

        echo view('admin/header',$data);
        echo view('admin/user/index',$data);
        echo view('admin/footer');
    

Model:
PHP Code:
class UserModel extends Model
{
    protected $db;
    protected $builder;

    function __construct()
    {
        $this->db = \Config\Database::connect();
        $this->builder $this->db->table('users');
    }
  /*
     * Get all users
     */
    function get_all_users()
    {

//        $this->builder->select('id_user, name_user');
        $this->builder->orderBy('id_user''asc');

        return $this->builder->get()->getResultArray();
    
Error:

Quote:Error
Call to a member function paginate() on array search →
Reply


Messages In This Thread
Pagination don't work - by dimonisse - 11-15-2019, 02:18 AM
RE: Pagination don't work - by pi26 - 02-18-2021, 10:55 AM
RE: Pagination don't work - by InsiteFX - 02-18-2021, 12:22 PM
RE: Pagination don't work - by wdeda - 02-18-2021, 02:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB