Welcome Guest, Not a member yet? Register   Sign In
Pagination with Custom model
#7

(This post was last modified: 01-04-2021, 01:56 PM by Mostafa Khudair.)

(12-31-2020, 03:59 AM)Here we go. Wrote: CONTROLLER:
PHP Code:
<?php

namespace App\Controllers;

use 
App\Models\CustomModel;

class 
Annunci extends BaseController
{

  public function index()
  {
     $model = new CustomModel();
     $data['annunci'] = $model->annunci();
     
$data['page']    = $model->pager;

     return view('cet'$data);
  }


MODEL:

PHP Code:
protected $table 'annunci';

public function 
annunci()
{
  return $this->orderBy('data''DESC')->paginate();


VIEW:
PHP Code:
<?php foreach ($annunci as $value): ?>
  <span><?= $value->id ?></span>
<?php endforeach ?>

It's very recommended to read userguide
Reply


Messages In This Thread
Pagination with Custom model - by AndreaL - 12-31-2020, 03:59 AM
RE: Pagination with Custom model - by InsiteFX - 12-31-2020, 12:27 PM
RE: Pagination with Custom model - by AndreaL - 01-04-2021, 03:03 AM
RE: Pagination with Custom model - by seunex - 01-04-2021, 04:01 AM
RE: Pagination with Custom model - by includebeer - 01-04-2021, 05:33 AM
RE: Pagination with Custom model - by AndreaL - 01-07-2021, 02:31 AM
RE: Pagination with Custom model - by rmcdahal - 01-04-2021, 06:29 AM
RE: Pagination with Custom model - by Mostafa Khudair - 01-04-2021, 10:04 AM
RE: Pagination with Custom model - by includebeer - 01-07-2021, 08:19 AM
RE: Pagination with Custom model - by AndreaL - 02-09-2021, 03:41 AM
RE: Pagination with Custom model - by MuhAnhar - 01-12-2021, 06:06 AM
RE: Pagination with Custom model - by includebeer - 01-12-2021, 03:46 PM
RE: Pagination with Custom model - by InsiteFX - 02-09-2021, 07:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB