]> BookStack Code Mirror - bookstack/blob - app/Activity/Controllers/AuditLogApiController.php
API: Added audit log list endpoint
[bookstack] / app / Activity / Controllers / AuditLogApiController.php
1 <?php
2
3 namespace BookStack\Activity\Controllers;
4
5 use BookStack\Activity\Models\Activity;
6 use BookStack\Http\ApiController;
7
8 class AuditLogApiController extends ApiController
9 {
10     /**
11      * Get a listing of audit log events in the system.
12      * The loggable relation fields currently only relates to core
13      * content types (page, book, bookshelf, chapter) but this may be
14      * used more in the future across other types.
15      * Requires permission to manage both users and system settings.
16      */
17     public function list()
18     {
19         $this->checkPermission('settings-manage');
20         $this->checkPermission('users-manage');
21
22         $query = Activity::query()->with(['user']);
23
24         return $this->apiListingResponse($query, [
25             'id', 'type', 'detail', 'user_id', 'loggable_id', 'loggable_type', 'ip', 'created_at',
26         ]);
27     }
28 }