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

daycry / auth / 23341393117

20 Mar 2026 11:45AM UTC coverage: 64.989% (+1.2%) from 63.745%
23341393117

push

github

daycry
Merge branch 'development' of https://github.com/daycry/auth into development

4 of 4 new or added lines in 2 files covered. (100.0%)

315 existing lines in 13 files now uncovered.

3306 of 5087 relevant lines covered (64.99%)

47.03 hits per line

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

13.04
/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
25✔
39
    {
40
        parent::initialize();
25✔
41

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

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

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

63
    /**
64
     * @param int|string $groupId
65
     */
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
     */
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