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

daycry / auth / 16267355898

03 Jul 2025 11:49AM UTC coverage: 59.854%. Remained the same
16267355898

push

github

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

13 of 21 new or added lines in 4 files covered. (61.9%)

28 existing lines in 2 files now uncovered.

1883 of 3146 relevant lines covered (59.85%)

22.26 hits per line

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

52.63
/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
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<UserGroup>
49
     */
50
    public function getForGroup(Group $group): ?array
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', null)
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
     */
66
    public function deleteAll($groupId): void
67
    {
UNCOV
68
        $return = $this->builder()
×
UNCOV
69
            ->where('group_id', $groupId)
×
UNCOV
70
            ->delete();
×
71

UNCOV
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
    {
UNCOV
81
        $return = $this->builder()
×
UNCOV
82
            ->where('group_id', $groupId)
×
UNCOV
83
            ->whereNotIn('permission_id', $cache)
×
UNCOV
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