adding app/models/Data/ActivityLog.php
This commit is contained in:
parent
05095a9c8e
commit
3f99105588
1 changed files with 131 additions and 0 deletions
131
app/models/Data/ActivityLog.php
Normal file
131
app/models/Data/ActivityLog.php
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Model\Data;
|
||||||
|
|
||||||
|
use \Phalcon\Paginator\Adapter\QueryBuilder;
|
||||||
|
|
||||||
|
class ActivityLog extends Base
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
|
||||||
|
protected $timestamp;
|
||||||
|
|
||||||
|
protected $user_id;
|
||||||
|
|
||||||
|
protected $ip;
|
||||||
|
|
||||||
|
protected $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $id
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTimestamp()
|
||||||
|
{
|
||||||
|
return $this->timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $timestamp
|
||||||
|
* @return ActivityLog
|
||||||
|
*/
|
||||||
|
public function setTimestamp($timestamp)
|
||||||
|
{
|
||||||
|
$this->timestamp = $timestamp;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getUserId()
|
||||||
|
{
|
||||||
|
return $this->user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $user_id
|
||||||
|
* @return ActivityLog
|
||||||
|
*/
|
||||||
|
public function setUserId($user_id)
|
||||||
|
{
|
||||||
|
$this->user_id = $user_id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getIp()
|
||||||
|
{
|
||||||
|
return $this->ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $ip
|
||||||
|
* @return ActivityLog
|
||||||
|
*/
|
||||||
|
public function setIp($ip)
|
||||||
|
{
|
||||||
|
$this->ip = $ip;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getMessage()
|
||||||
|
{
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $message
|
||||||
|
* @return ActivityLog
|
||||||
|
*/
|
||||||
|
public function setMessage($message)
|
||||||
|
{
|
||||||
|
$this->message = $message;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userid
|
||||||
|
* @param int $page
|
||||||
|
* @param int $limit
|
||||||
|
* @return \Phalcon\Paginator\AdapterInterface
|
||||||
|
*/
|
||||||
|
public static function getPaginationList($userid, $page = 1, $limit = 30)
|
||||||
|
{
|
||||||
|
$builder = (new self())->getModelsManager()->createBuilder();
|
||||||
|
|
||||||
|
$builder->from(self::class)
|
||||||
|
->where('user_id = :uid:', array('uid' => $userid))
|
||||||
|
->orderBy('timestamp DESC');
|
||||||
|
|
||||||
|
$paginator = new QueryBuilder(array(
|
||||||
|
'builder' => $builder,
|
||||||
|
'page' => $page,
|
||||||
|
'limit' => $limit
|
||||||
|
));
|
||||||
|
|
||||||
|
return $paginator;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in a new issue