Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Pagination
#1
Heart 
(This post was last modified: 05-23-2019, 04:34 AM by gabrielcantarin.)

Using this method the pagination is working fine! But how can I filter the data? For example I'm logged with user id: 1 and I want to see only companies that belongs to this user.

Using the instance like this I'll always get all the rows of this table =/

public function list(){
        $companyModel = new CompanyModel();
        
        $data = [
            'obj' => $companyModel->paginate(20, 'group1'),
            'pager' => $companyModel->pager
        ];
        
        echo view('Template/header');
        echo view('Company/listar', $data);
        echo view('Template/footer');
 }
Reply
#2

Code:
$companyModel
    ->where('user_id', 1)
    ->paginate(20, 'group1'),
Reply
#3

Thank you a lot [b]kilishan[/b]!!!!

This works!
Code:
$companyModel
   ->where('user_id', 1)
   ->paginate(20, 'group1'),

This DONT work
Code:
$companyModel
   ->paginate(20, 'group1'),
   ->where('user_id', 1)

Pay attention in the order when creating a pagination guys!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB