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

AJenbo / agcms / 20972217862

13 Jan 2026 08:53PM UTC coverage: 53.678% (+0.1%) from 53.541%
20972217862

Pull #74

github

web-flow
Merge 4fdfac7ee into 498ff829e
Pull Request #74: Add PHP versions 8.4 to 8.5 to CI matrix

248 of 345 new or added lines in 40 files covered. (71.88%)

6 existing lines in 5 files now uncovered.

2780 of 5179 relevant lines covered (53.68%)

13.06 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\Exception;
6
use App\Exceptions\InvalidInput;
7
use App\Http\Request;
8
use App\Models\CustomSorting;
9
use App\Models\Page;
10
use App\Models\Table;
11
use App\Services\OrmService;
12
use Symfony\Component\HttpFoundation\JsonResponse;
13
use Symfony\Component\HttpFoundation\Response;
14

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

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

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

48
    /**
49
     * Add row to a table.
50
     */
51
    public function addRow(Request $request, int $tableId): JsonResponse
52
    {
NEW
53
        $cells = [];
×
NEW
54
        foreach ($request->request->all('cells') as $cell) {
×
NEW
55
            if (!is_string($cell)) {
×
NEW
56
                throw new Exception(_('Invalid cell type: ') . gettype($cell));
×
57
            }
NEW
58
            $cells[] = $cell;
×
59
        }
60

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

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

74
        $rowId = $table->addRow($cells, $link);
×
75

76
        return new JsonResponse(['listid' => $tableId, 'rowid' => $rowId]);
×
77
    }
78

79
    public function updateRow(Request $request, int $tableId, int $rowId): JsonResponse
80
    {
NEW
81
        $cells = [];
×
NEW
82
        foreach ($request->request->all('cells') as $cell) {
×
NEW
83
            if (!is_string($cell)) {
×
NEW
84
                throw new Exception(_('Invalid cell type: ') . gettype($cell));
×
85
            }
NEW
86
            $cells[] = $cell;
×
87
        }
88

89
        $link = $request->getRequestInt('link');
×
90
        if ($link) {
×
91
            $page = app(OrmService::class)->getOne(Page::class, $link);
×
92
            if (!$page) {
×
93
                throw new InvalidInput(_('Linked page not found.'), Response::HTTP_NOT_FOUND);
×
94
            }
95
        }
96

97
        $table = app(OrmService::class)->getOne(Table::class, $tableId);
×
98
        if (!$table) {
×
99
            throw new InvalidInput(_('Table not found.'), Response::HTTP_NOT_FOUND);
×
100
        }
101

102
        $table->updateRow($rowId, $cells, $link);
×
103

104
        return new JsonResponse(['listid' => $tableId, 'rowid' => $rowId]);
×
105
    }
106

107
    public function removeRow(Request $request, int $tableId, int $rowId): JsonResponse
108
    {
109
        $table = app(OrmService::class)->getOne(Table::class, $tableId);
×
110
        if (!$table) {
×
111
            throw new InvalidInput(_('Table not found.'), Response::HTTP_NOT_FOUND);
×
112
        }
113

114
        $table->removeRow($rowId);
×
115

116
        return new JsonResponse(['listid' => $tableId, 'rowid' => $rowId]);
×
117
    }
118
}
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