summaryrefslogtreecommitdiff
path: root/includes/pages/admin_log.php
blob: 2a736aa5b1af8fa957b6c53427913119269b6f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

use Engelsystem\Models\LogEntry;

/**
 * @return string
 */
function admin_log_title()
{
    return __('Log');
}

/**
 * @return string
 */
function admin_log()
{
    $filter = '';
    if (request()->has('keyword')) {
        $filter = strip_request_item('keyword');
    }

    $log_entries = LogEntry::filter($filter);

    $entries = [];
    foreach ($log_entries as $entry) {
        $data = $entry->toArray();
        $data['created_at'] = date_format($entry->created_at, 'd.m.Y H:i');
        $entries[] = $data;
    }

    return page_with_title(admin_log_title(), [
        msg(),
        form([
            form_text('keyword', __('Search'), $filter),
            form_submit(__('Search'), 'Go')
        ]),
        table([
            'created_at' => 'Time',
            'level'      => 'Type',
            'message'    => 'Log Entry'
        ], $entries)
    ]);
}