Guillermo - add creatae log architecture [skip ci]
This commit is contained in:
parent
b718598f32
commit
c7cdfd7318
|
@ -5,6 +5,7 @@ require_once 'system/edit-settings.php';
|
|||
require_once 'system/add-department.php';
|
||||
require_once 'system/edit-department.php';
|
||||
require_once 'system/delete-department.php';
|
||||
require_once 'system/get-logs.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/system');
|
||||
|
@ -15,6 +16,6 @@ $systemControllerGroup->addController(new EditSettingsController);
|
|||
$systemControllerGroup->addController(new AddDepartmentController);
|
||||
$systemControllerGroup->addController(new EditDepartmentController);
|
||||
$systemControllerGroup->addController(new DeleteDepartmentController);
|
||||
|
||||
$systemControllerGroup->addController(new GetLogsController);
|
||||
|
||||
$systemControllerGroup->finalize();
|
|
@ -18,5 +18,8 @@ class GetLogsController extends Controller {
|
|||
|
||||
public function handler() {
|
||||
$page =Controller::request('page');
|
||||
$logList = Log::find('LIMIT ? OFFSET ?', [10, 10*($page-1)+1]);
|
||||
|
||||
Response::respondSuccess($logList->toArray());
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ class Log extends DataStore {
|
|||
public static function getProps() {
|
||||
return [
|
||||
'type',
|
||||
'author',
|
||||
'authorUser',
|
||||
'authorStaff',
|
||||
'to'
|
||||
];
|
||||
|
@ -20,10 +20,17 @@ class Log extends DataStore {
|
|||
|
||||
$log->setProperties(array(
|
||||
'type' => $type,
|
||||
'author' => (!$author->isNull() && !$author->staff) ? $author : null,
|
||||
'authorUser' => (!$author->isNull() && !$author->staff) ? $author : null,
|
||||
'authorStaff' => (!$author->isNull() && $author->staff) ? $author : null,
|
||||
'to' => $to,
|
||||
));
|
||||
$log->store();
|
||||
}
|
||||
public function toArray() {
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'to' => $this->to,
|
||||
'author' => ($this->authorUser) ? $this->authorUser->toArray() : $this->authorStaff->toArray()
|
||||
];
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ class Scripts
|
|||
})
|
||||
|
||||
if response['status'] === 'fail'
|
||||
raise 'Could not create user'
|
||||
raise response['message']
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue