• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AJenbo / agcms / 20972494104

13 Jan 2026 09:02PM UTC coverage: 53.72% (+0.2%) from 53.541%
20972494104

push

github

AJenbo
Upgrade codebase to support PHP 8.5 compatibility

247 of 340 new or added lines in 40 files covered. (72.65%)

6 existing lines in 5 files now uncovered.

2780 of 5175 relevant lines covered (53.72%)

13.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/application/inc/Http/Controllers/Admin/TableController.php
1
<?php
2

3
namespace App\Http\Controllers\Admin;
4

5
use App\Exceptions\InvalidInput;
6
use App\Http\Request;
7
use App\Models\CustomSorting;
8
use App\Models\Page;
9
use App\Models\Table;
10
use App\Services\OrmService;
11
use Symfony\Component\HttpFoundation\JsonResponse;
12
use Symfony\Component\HttpFoundation\Response;
13

14
class TableController extends AbstractAdminController
15
{
16
    /**
17
     * Add table to page.
18
     */
19
    public function create(Request $request): JsonResponse
20
    {
21
        $table = new Table([
×
22
            'page_id'     => $request->request->getInt('page_id'),
×
23
            'title'       => $request->getRequestString('title'),
×
24
            'column_data' => json_encode($request->request->all('columns'), JSON_THROW_ON_ERROR),
×
25
            'order_by'    => $request->request->getInt('order_by'),
×
26
            'has_links'   => $request->request->getBoolean('has_links'),
×
27
        ]);
28
        $table->save();
×
29

30
        return new JsonResponse([]);
×
31
    }
32

33
    /**
34
     * Add table to page.
35
     */
36
    public function createDialog(Request $request, int $pageId): Response
37
    {
38
        return $this->render(
×
39
            'admin/addlist',
40
            [
41
                'customSortings' => app(OrmService::class)->getByQuery(CustomSorting::class, 'SELECT * FROM `tablesort`'),
×
42
                'page_id'        => $pageId,
43
            ]
44
        );
45
    }
46

47
    /**
48
     * Add row to a table.
49
     */
50
    public function addRow(Request $request, int $tableId): JsonResponse
51
    {
NEW
52
        $cells = [];
×
NEW
53
        foreach ($request->request->all('cells') as $cell) {
×
NEW
54
            $cells[] = valstring($cell);
×
55
        }
56

57
        $link = $request->getRequestInt('link');
×
58
        if ($link) {
×
59
            $page = app(OrmService::class)->getOne(Page::class, $link);
×
60
            if (!$page) {
×
61
                throw new InvalidInput(_('Linked page not found.'), Response::HTTP_NOT_FOUND);
×
62
            }
63
        }
64

65
        $table = app(OrmService::class)->getOne(Table::class, $tableId);
×
66
        if (!$table) {
×
67
            throw new InvalidInput(_('Table not found.'), Response::HTTP_NOT_FOUND);
×
68
        }
69

70
        $rowId = $table->addRow($cells, $link);
×
71

72
        return new JsonResponse(['listid' => $tableId, 'rowid' => $rowId]);
×
73
    }
74

75
    public function updateRow(Request $request, int $tableId, int $rowId): JsonResponse
76
    {
NEW
77
        $cells = [];
×
NEW
78
        foreach ($request->request->all('cells') as $cell) {
×
NEW
79
            $cells[] = valstring($cell);
×
80
        }
81

82
        $link = $request->getRequestInt('link');
×
83
        if ($link) {
×
84
            $page = app(OrmService::class)->getOne(Page::class, $link);
×
85
            if (!$page) {
×
86
                throw new InvalidInput(_('Linked page not found.'), Response::HTTP_NOT_FOUND);
×
87
            }
88
        }
89

90
        $table = app(OrmService::class)->getOne(Table::class, $tableId);
×
91
        if (!$table) {
×
92
            throw new InvalidInput(_('Table not found.'), Response::HTTP_NOT_FOUND);
×
93
        }
94

95
        $table->updateRow($rowId, $cells, $link);
×
96

97
        return new JsonResponse(['listid' => $tableId, 'rowid' => $rowId]);
×
98
    }
99

100
    public function removeRow(Request $request, int $tableId, int $rowId): JsonResponse
101
    {
102
        $table = app(OrmService::class)->getOne(Table::class, $tableId);
×
103
        if (!$table) {
×
104
            throw new InvalidInput(_('Table not found.'), Response::HTTP_NOT_FOUND);
×
105
        }
106

107
        $table->removeRow($rowId);
×
108

109
        return new JsonResponse(['listid' => $tableId, 'rowid' => $rowId]);
×
110
    }
111
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc