app/models/Data/ActivityLog.php: implement getAllPaginationList()
This commit is contained in:
parent
a01cc60266
commit
778c7127b3
1 changed files with 22 additions and 1 deletions
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Model\Data;
|
namespace App\Model\Data;
|
||||||
|
|
||||||
use \Phalcon\Paginator\Adapter\QueryBuilder;
|
use Phalcon\Mvc\Model\Query\BuilderInterface,
|
||||||
|
Phalcon\Paginator\Adapter\QueryBuilder;
|
||||||
|
|
||||||
class ActivityLog extends Base
|
class ActivityLog extends Base
|
||||||
{
|
{
|
||||||
|
|
@ -129,6 +130,26 @@ class ActivityLog extends Base
|
||||||
->where('user_id = :uid:', array('uid' => $userid))
|
->where('user_id = :uid:', array('uid' => $userid))
|
||||||
->orderBy('timestamp DESC');
|
->orderBy('timestamp DESC');
|
||||||
|
|
||||||
|
return self::_paginate($builder, $page, $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page
|
||||||
|
* @param int $limit
|
||||||
|
* @return \Phalcon\Paginator\AdapterInterface
|
||||||
|
*/
|
||||||
|
public static function getAllPaginationList($page = 1, $limit = 30)
|
||||||
|
{
|
||||||
|
$builder = (new self())->getModelsManager()->createBuilder();
|
||||||
|
|
||||||
|
$builder->from(self::class)
|
||||||
|
->orderBy('timestamp DESC');
|
||||||
|
|
||||||
|
return self::_paginate($builder, $page, $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function _paginate(BuilderInterface $builder, $page = 1, $limit = 30)
|
||||||
|
{
|
||||||
$paginator = new QueryBuilder(array(
|
$paginator = new QueryBuilder(array(
|
||||||
'builder' => $builder,
|
'builder' => $builder,
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
|
|
|
||||||
Reference in a new issue