Files
NewTicket/app/common/service/TicketScope.php
2026-08-19 19:56:47 +08:00

36 lines
1012 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\common\service;
/**
* 把当前用户能看哪些工单封装成一个明确的对象TicketScope,避免用零散变量或含义不清的数组传递数据范围
* final 表示不允许被其他类继承
*/
final class TicketScope
{
# readonly 仅在PHP8.1中存在,当前版本8.0.2
private function __construct(
public string $type,
public ?int $staffId = null,
public ?int $clientId = null
) {}
/** 管理员:不限制状态、不限制归属 */
public static function admin(): self
{
return new self('admin');
}
/** 员工:未分配全部可见,其余状态仅自己 */
public static function staff(int $staffId): self
{
return new self('staff', staffId: $staffId);
}
/** 客户:$clientId 只能看自己的,传null可以看当前公司所有的 */
public static function client(?int $clientId): self
{
return new self('client', clientId: $clientId);
}
}