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

daycry / auth / 22527357078

28 Feb 2026 07:22PM UTC coverage: 63.267% (+0.7%) from 62.568%
22527357078

push

github

daycry
Remove PHP 8.1 from PHPUnit CI matrix

Update .github/workflows/phpunit.yml to drop PHP 8.1 from the test matrix. CI will now run PHPUnit only on PHP 8.2 and 8.3, reducing the matrix to current supported versions.

3064 of 4843 relevant lines covered (63.27%)

41.52 hits per line

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

0.0
/src/Controllers/Admin/PermissionsController.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Auth.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Auth\Controllers\Admin;
15

16
use CodeIgniter\HTTP\RedirectResponse;
17
use Daycry\Auth\Entities\Permission;
18
use Daycry\Auth\Models\PermissionModel;
19

20
/**
21
 * Admin Permissions Controller — CRUD for individual permissions.
22
 */
23
class PermissionsController extends BaseAdminController
24
{
25
    /**
26
     * List all permissions.
27
     */
28
    public function index(): string
×
29
    {
30
        /** @var PermissionModel $permissionModel */
31
        $permissionModel = model(PermissionModel::class);
×
32

33
        $permissions = $permissionModel->orderBy('name')->findAll();
×
34

35
        return $this->view('Daycry\\Auth\\Views\\admin\\permissions\\index', [
×
36
            'permissions' => $permissions,
×
37
        ]);
×
38
    }
39

40
    /**
41
     * Show the create form.
42
     */
43
    public function create(): string
×
44
    {
45
        return $this->view('Daycry\\Auth\\Views\\admin\\permissions\\form', [
×
46
            'permission' => null,
×
47
        ]);
×
48
    }
49

50
    /**
51
     * Persist a new permission.
52
     */
53
    public function store(): RedirectResponse
×
54
    {
55
        /** @var PermissionModel $permissionModel */
56
        $permissionModel = model(PermissionModel::class);
×
57

58
        $name = trim((string) $this->request->getPost('name'));
×
59

60
        if ($name === '') {
×
61
            return redirect()->route('admin-permission-create')->with('error', 'Permission name is required.');
×
62
        }
63

64
        $perm       = new Permission();
×
65
        $perm->name = $name;
×
66

67
        if (! $permissionModel->save($perm)) {
×
68
            return redirect()->route('admin-permission-create')
×
69
                ->with('errors', $permissionModel->errors());
×
70
        }
71

72
        return redirect()->route('admin-permissions')
×
73
            ->with('message', "Permission \"{$name}\" created.");
×
74
    }
75

76
    /**
77
     * Show the edit form.
78
     *
79
     * @param int|string $id
80
     */
81
    public function edit($id): RedirectResponse|string
×
82
    {
83
        $perm = $this->findPermOr404((int) $id);
×
84

85
        if ($perm instanceof RedirectResponse) {
×
86
            return $perm;
×
87
        }
88

89
        return $this->view('Daycry\\Auth\\Views\\admin\\permissions\\form', [
×
90
            'permission' => $perm,
×
91
        ]);
×
92
    }
93

94
    /**
95
     * Persist edits.
96
     *
97
     * @param int|string $id
98
     */
99
    public function update($id): RedirectResponse
×
100
    {
101
        $perm = $this->findPermOr404((int) $id);
×
102

103
        if ($perm instanceof RedirectResponse) {
×
104
            return $perm;
×
105
        }
106

107
        /** @var PermissionModel $permissionModel */
108
        $permissionModel = model(PermissionModel::class);
×
109

110
        $name = trim((string) $this->request->getPost('name'));
×
111

112
        if ($name !== '') {
×
113
            $perm->name = $name;
×
114
        }
115

116
        $permissionModel->save($perm);
×
117

118
        return redirect()->route('admin-permissions')
×
119
            ->with('message', 'Permission updated.');
×
120
    }
121

122
    /**
123
     * Delete a permission.
124
     *
125
     * @param int|string $id
126
     */
127
    public function delete($id): RedirectResponse
×
128
    {
129
        $perm = $this->findPermOr404((int) $id);
×
130

131
        if ($perm instanceof RedirectResponse) {
×
132
            return $perm;
×
133
        }
134

135
        /** @var PermissionModel $permissionModel */
136
        $permissionModel = model(PermissionModel::class);
×
137
        $permissionModel->delete($perm->id, true);
×
138

139
        return redirect()->route('admin-permissions')
×
140
            ->with('message', "Permission \"{$perm->name}\" deleted.");
×
141
    }
142

143
    // ── Private helpers ───────────────────────────────────────────
144

145
    private function findPermOr404(int $id): Permission|RedirectResponse
×
146
    {
147
        /** @var PermissionModel $permissionModel */
148
        $permissionModel = model(PermissionModel::class);
×
149
        $perm            = $permissionModel->find($id);
×
150

151
        if ($perm === null) {
×
152
            return redirect()->route('admin-permissions')->with('error', 'Permission not found.');
×
153
        }
154

155
        return $perm;
×
156
    }
157
}
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