1
|
|
|
<?php |
2
|
|
|
namespace App\Schema; |
3
|
|
|
|
4
|
|
|
use \Carbon\Carbon; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @api {get} /log?page[number]=1&page[size]=15 Список логов |
8
|
|
|
* @apiName GetLogs |
9
|
|
|
* @apiGroup Log |
10
|
|
|
* |
11
|
|
|
* @apiDescription Метод для получения списка логов. |
12
|
|
|
* |
13
|
|
|
* @apiPermission user |
14
|
|
|
* |
15
|
|
|
* @apiHeader {String} Authorization Токен. |
16
|
|
|
* |
17
|
|
|
* @apiSuccessExample {json} Успешно (200) |
18
|
|
|
* HTTP/1.1 200 OK |
19
|
|
|
* { |
20
|
|
|
* "meta": { |
21
|
|
|
* "total": 21, |
22
|
|
|
* "count": 5 |
23
|
|
|
* }, |
24
|
|
|
* "links": { |
25
|
|
|
* "self": "http://bootstrapi.dev/api/log?page[number]=1&page[size]=5", |
26
|
|
|
* "first": "http://bootstrapi.dev/api/log?page[number]=1&page[size]=5", |
27
|
|
|
* "last": "http://bootstrapi.dev/api/log?page[number]=5&page[size]=5", |
28
|
|
|
* "next": "http://bootstrapi.dev/api/log?page[number]=2&page[size]=5" |
29
|
|
|
* }, |
30
|
|
|
* "data": [ |
31
|
|
|
* { |
32
|
|
|
* "type": "log", |
33
|
|
|
* "id": "1", |
34
|
|
|
* "attributes": { |
35
|
|
|
* "action": "CREATE", |
36
|
|
|
* "entity_id": 1, |
37
|
|
|
* "entity_type": "App\\Model\\Right", |
38
|
|
|
* "state": "{\"name\":\"manageUsers\",\"description\":\"\\u0423\\u043f\\u0440\\u0430\\u0432\\u043b\\u0435\\u043d\\u0438\\u0435 \\u043f\\u043e\\u043b\\u044c\\u0437\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044f\\u043c\\u0438\",\"created_by\":1,\"updated_at\":\"2016-10-16 18:19:34\",\"created_at\":\"2016-10-16 18:19:34\",\"id\":1}", |
39
|
|
|
* "created_at": "2016-10-17T07:38:21+0000", |
40
|
|
|
* "created_by": 1 |
41
|
|
|
* }, |
42
|
|
|
* "links": { |
43
|
|
|
* "self": "http://bootstrapi.dev/api/log/1" |
44
|
|
|
* } |
45
|
|
|
* } |
46
|
|
|
* ] |
47
|
|
|
* } |
48
|
|
|
* |
49
|
|
|
* @apiUse StandardErrors |
50
|
|
|
* @apiUse UnauthorizedError |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @api {get} /log/:id Получить лог |
55
|
|
|
* @apiName GetLog |
56
|
|
|
* @apiGroup Log |
57
|
|
|
* |
58
|
|
|
* @apiDescription Метод для получения лога. |
59
|
|
|
* |
60
|
|
|
* @apiPermission user |
61
|
|
|
* |
62
|
|
|
* @apiParam {Number} id Id лога |
63
|
|
|
* |
64
|
|
|
* @apiHeader {String} Authorization Токен. |
65
|
|
|
* |
66
|
|
|
* @apiSuccessExample {json} Успешно (200) |
67
|
|
|
* HTTP/1.1 200 OK |
68
|
|
|
* { |
69
|
|
|
* "data": { |
70
|
|
|
* "type": "log", |
71
|
|
|
* "id": "1", |
72
|
|
|
* "attributes": { |
73
|
|
|
* "action": "CREATE", |
74
|
|
|
* "entity_id": 1, |
75
|
|
|
* "entity_type": "App\\Model\\Right", |
76
|
|
|
* "state": "{\"name\":\"manageUsers\",\"description\":\"\\u0423\\u043f\\u0440\\u0430\\u0432\\u043b\\u0435\\u043d\\u0438\\u0435 \\u043f\\u043e\\u043b\\u044c\\u0437\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044f\\u043c\\u0438\",\"created_by\":1,\"updated_at\":\"2016-10-16 18:19:34\",\"created_at\":\"2016-10-16 18:19:34\",\"id\":1}", |
77
|
|
|
* "created_at": "2016-10-17T07:38:21+0000", |
78
|
|
|
* "created_by": 1 |
79
|
|
|
* }, |
80
|
|
|
* "links": { |
81
|
|
|
* "self": "http://bootstrapi.dev/api/log/1" |
82
|
|
|
* } |
83
|
|
|
* } |
84
|
|
|
* } |
85
|
|
|
* |
86
|
|
|
* @apiUse StandardErrors |
87
|
|
|
* @apiUse UnauthorizedError |
88
|
|
|
* @apiUse NotFoundError |
89
|
|
|
*/ |
90
|
|
|
|
91
|
|
|
final class LogSchema extends BaseSchema |
92
|
|
|
{ |
93
|
|
|
protected $resourceType = 'log'; |
94
|
|
|
|
95
|
|
|
public function getId($log) |
96
|
|
|
{ |
97
|
|
|
return $log->id; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getAttributes($log) |
101
|
|
|
{ |
102
|
|
|
return [ |
103
|
|
|
'action' => $log->action, |
104
|
|
|
'entity_id' => (int) $log->entity_id, |
105
|
|
|
'entity_type' => $log->entity_type, |
106
|
|
|
'state' => $log->state, |
107
|
|
|
'created_at' => Carbon::parse($log->created_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
108
|
|
|
'created_by' => $log->created_by, |
109
|
|
|
]; |
110
|
|
|
} |
111
|
|
|
} |