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

daycry / auth / 22527658769

28 Feb 2026 07:41PM UTC coverage: 63.267% (-3.6%) from 66.864%
22527658769

push

github

web-flow
Merge pull request #36 from daycry/development

Implement TOTP 2FA, JWT auth, device session tracking, and docs overhaul

465 of 1168 new or added lines in 52 files covered. (39.81%)

129 existing lines in 46 files now uncovered.

3064 of 4843 relevant lines covered (63.27%)

41.53 hits per line

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

52.17
/src/Models/PermissionGroupModel.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\Models;
15

16
use CodeIgniter\I18n\Time;
17
use Daycry\Auth\Entities\Group;
18
use Daycry\Auth\Entities\PermissionGroup;
19

20
class PermissionGroupModel extends BaseModel
21
{
22
    protected $primaryKey     = 'id';
23
    protected $returnType     = PermissionGroup::class;
24
    protected $useSoftDeletes = false;
25
    protected $allowedFields  = [
26
        'group_id',
27
        'permission_id',
28
        'until_at',
29
    ];
30
    protected $useTimestamps      = true;
31
    protected $createdField       = 'created_at';
32
    protected $updatedField       = 'updated_at';
33
    protected $deletedField       = 'deleted_at';
34
    protected $validationRules    = [];
35
    protected $validationMessages = [];
36
    protected $skipValidation     = false;
37

38
    protected function initialize(): void
6✔
39
    {
40
        parent::initialize();
6✔
41

42
        $this->table = $this->tables['permissions_groups'];
6✔
43
    }
44

45
    /**
46
     * Returns all permissions groups.
47
     *
48
     * @return list<PermissionGroup>|null
49
     */
50
    public function getForGroup(Group $group): ?array
5✔
51
    {
52
        $now = Time::now()->format('Y-m-d H:i:s');
5✔
53

54
        return $this->where('group_id', $group->id)
5✔
55
            ->groupStart()
5✔
56
            ->where('until_at')
5✔
57
            ->orWhere('until_at >', $now)
5✔
58
            ->groupEnd()
5✔
59
            ->orderBy($this->primaryKey)
5✔
60
            ->findAll();
5✔
61
    }
62

63
    /**
64
     * @param int|string $groupId
65
     */
UNCOV
66
    public function deleteAll($groupId): void
×
67
    {
68
        $return = $this->builder()
×
69
            ->where('group_id', $groupId)
×
70
            ->delete();
×
71

72
        $this->checkQueryReturn($return);
×
73
    }
74

75
    /**
76
     * @param int|string $groupId
77
     * @param mixed      $cache
78
     */
UNCOV
79
    public function deleteNotIn($groupId, $cache): void
×
80
    {
81
        $return = $this->builder()
×
82
            ->where('group_id', $groupId)
×
83
            ->whereNotIn('permission_id', $cache)
×
84
            ->delete();
×
85

86
        $this->checkQueryReturn($return);
×
87
    }
88
}
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