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

miaoxing / app / 13100242664

02 Feb 2025 03:42PM UTC coverage: 22.581%. Remained the same
13100242664

push

github

semantic-release-bot
chore(release): publish

See CHANGELOG.md for more details.

42 of 186 relevant lines covered (22.58%)

3.48 hits per line

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

0.0
/src/Service/RoleModel.php
1
<?php
2

3
namespace Miaoxing\App\Service;
4

5
use Miaoxing\Plugin\BaseModel;
6
use Miaoxing\Plugin\Model\HasAppIdTrait;
7
use Miaoxing\Plugin\Model\ModelTrait;
8
use Miaoxing\Plugin\Model\ReqQueryTrait;
9
use Miaoxing\Plugin\Model\SnowflakeTrait;
10
use Wei\Model\SoftDeleteTrait;
11
use Wei\Ret;
12

13
/**
14
 * @property string|null $id 编号
15
 * @property string $appId 应用编号
16
 * @property string $parentId 父级角色编号
17
 * @property int $level 层级
18
 * @property string $name 名称
19
 * @property string $code 标识
20
 * @property string $description 描述
21
 * @property bool $isEnabled 是否启用
22
 * @property array $actions 菜单和操作
23
 * @property string|null $createdAt
24
 * @property string|null $updatedAt
25
 * @property string $createdBy
26
 * @property string $updatedBy
27
 * @property string|null $deletedAt
28
 * @property string $deletedBy
29
 * @property PermissionModel|PermissionModel[] $permissions
30
 * @property PermissionModel|PermissionModel[] $enabledPermissions
31
 * @property string|null $id 编号
32
 * @property string $appId 应用编号
33
 * @property string $parentId 父级角色编号
34
 * @property int $level 层级
35
 * @property string $name 名称
36
 * @property string $code 标识
37
 * @property string $description 描述
38
 * @property bool $isEnabled 是否启用
39
 * @property array $actions 菜单和操作
40
 * @property string|null $createdAt
41
 * @property string|null $updatedAt
42
 * @property string $createdBy
43
 * @property string $updatedBy
44
 * @property string|null $deletedAt
45
 * @property string $deletedBy
46
 */
47
class RoleModel extends BaseModel
48
{
49
    use HasAppIdTrait;
50
    use ModelTrait;
51
    use ReqQueryTrait;
52
    use SnowflakeTrait;
53
    use SoftDeleteTrait;
54

55
    /**
56
     * @return PermissionModel|PermissionModel[]
57
     */
58
    public function permissions(): PermissionModel
59
    {
60
        return $this->belongsToMany(PermissionModel::class)->whereNull('permissions_roles.deleted_at');
×
61
    }
62

63
    /**
64
     * @return PermissionModel|PermissionModel[]
65
     */
66
    public function enabledPermissions(): PermissionModel
67
    {
68
        return $this->permissions()->where('isEnabled', true);
×
69
    }
70

71
    public function checkDestroy(): Ret
72
    {
73
        if (RolesUserModel::findBy('roleId', $this->id)) {
×
74
            return err(['很抱歉,该%s已被%s使用,不能删除', '角色', '用户']);
×
75
        }
76
        return suc();
×
77
    }
78
}
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

© 2025 Coveralls, Inc