2016-12-29 01:55:00 +01:00
|
|
|
<?php
|
|
|
|
use Respect\Validation\Validator as DataValidator;
|
|
|
|
|
2017-04-18 02:09:16 +02:00
|
|
|
/**
|
2017-05-12 06:58:40 +02:00
|
|
|
* @api {post} /system/get-logs Get logs
|
2017-06-28 15:02:54 +02:00
|
|
|
* @apiVersion 4.1.0
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
|
|
|
* @apiName Get logs
|
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiGroup System
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiDescription This path retrieves the all the logs.
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiPermission staff1
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiParam {Number} page The page of logs.
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiUse NO_PERMISSION
|
|
|
|
* @apiUse INVALID_PAGE
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
2017-04-22 03:33:17 +02:00
|
|
|
* @apiSuccess {[Log](#api-Data_Structures-ObjectLog)[]} data Array of last logs
|
2017-04-18 02:09:16 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-12-29 01:55:00 +01:00
|
|
|
class GetLogsController extends Controller {
|
|
|
|
const PATH = '/get-logs';
|
2017-02-08 19:09:15 +01:00
|
|
|
const METHOD = 'POST';
|
2016-12-29 01:55:00 +01:00
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
|
|
|
'permission' => 'staff_1',
|
|
|
|
'requestData' => [
|
|
|
|
'page' => [
|
|
|
|
'validation' => DataValidator::numeric(),
|
|
|
|
'error' => ERRORS::INVALID_PAGE
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
2017-01-05 20:26:43 +01:00
|
|
|
$page = Controller::request('page');
|
2017-01-11 04:21:27 +01:00
|
|
|
$logList = Log::find('ORDER BY id desc LIMIT ? OFFSET ?', [10, 10*($page-1)]);
|
2016-12-29 06:04:35 +01:00
|
|
|
|
|
|
|
Response::respondSuccess($logList->toArray());
|
2016-12-29 01:55:00 +01:00
|
|
|
}
|
|
|
|
}
|