OfficerPolicy
extends BasePolicy
in package
Officer Authorization Policy
Controls entity-level access for Officer operations including assignment, release, warrant management, and hierarchical access control. Implements dual ownership model (self-access + administrative access) and office-specific authorization.
Tags
Table of Contents
Methods
- before() : bool|null
- Check if $user is a super user and can skip auth with an auto True
- canAdd() : bool
- Check if $user can add RolesPermissions
- canAssign() : bool
- Check if user can assign officers within branch context.
- canBranchOfficers() : bool
- Check if user can view branch officers.
- canDelete() : bool
- Check if $user can delete RolesPermissions
- canEdit() : bool
- Check if user can edit an officer. Validates both permission and office access.
- canGridData() : bool
- Check if $user can view role
- canIndex() : bool
- Check if $user can view role
- canMemberOfficers() : bool
- Check if user can view member officers. Members can view their own assignments.
- canOfficers() : bool
- Check if user has general officer access.
- canOfficersByWarrantStatus() : bool
- Check if user can view officers by warrant status.
- canRelease() : bool
- Check if user can release an officer. Validates both permission and office access.
- canRequestWarrant() : bool
- Check if user can request warrant. Members can request for their own assignments.
- canView() : bool
- Check if $user can view RolesPermissions
- canViewPrivateNotes() : bool
- Check if $user can view hidden
- canWorkWithAllOfficers() : bool
- Check if user can work with all officers across the organization.
- canWorkWithOfficerDeputies() : bool
- Check if user can work with officer deputies.
- canWorkWithOfficerDirectReports() : bool
- Check if user can work with direct report officers.
- canWorkWithOfficerReportingTree() : bool
- Check if user can work with officers in their reporting tree.
- scopeIndex() : mixed
- Apply scope for index action.
- _getBranchIdsForPolicy() : array<string|int, mixed>|null
- Check if $user can view hidden
- _getPermissions() : bool
- Check if $user can view hidden
- _getPolicies() : bool
- Check if $user can view hidden
- _hasPolicy() : bool
- Check if $user can view hidden
- _hasPolicyForUrl() : bool
- Check if $user can view hidden
- _isSuperUser() : bool
- Check if $user is a super user
- canManageOfficerMember() : bool
- Determine whether the user can manage officer actions for a member.
Methods
before()
Check if $user is a super user and can skip auth with an auto True
public
before(KmpIdentityInterface $user, mixed $resource, string $action) : bool|null
Parameters
- $user : KmpIdentityInterface
-
The user.
- $resource : mixed
-
The resource.
- $action : string
-
The action.
Return values
bool|nullcanAdd()
Check if $user can add RolesPermissions
public
canAdd(KmpIdentityInterface $user, BaseEntity|Table $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity|Table
- $optionalArgs : mixed
Return values
boolcanAssign()
Check if user can assign officers within branch context.
public
canAssign(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Assignment context entity
- $optionalArgs : mixed
-
[0] = branchId
Return values
boolcanBranchOfficers()
Check if user can view branch officers.
public
canBranchOfficers(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
All authenticated members can view branch officers (public information).
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Context entity
- $optionalArgs : mixed
-
Additional parameters
Return values
boolcanDelete()
Check if $user can delete RolesPermissions
public
canDelete(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanEdit()
Check if user can edit an officer. Validates both permission and office access.
public
canEdit(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity to edit
- $optionalArgs : mixed
-
[0] = branchId override
Return values
boolcanGridData()
Check if $user can view role
public
canGridData(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanIndex()
Check if $user can view role
public
canIndex(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanMemberOfficers()
Check if user can view member officers. Members can view their own assignments.
public
canMemberOfficers(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity with member_id
- $optionalArgs : mixed
-
Additional parameters
Return values
boolcanOfficers()
Check if user has general officer access.
public
canOfficers(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Context entity
- $optionalArgs : mixed
-
Additional parameters
Return values
boolcanOfficersByWarrantStatus()
Check if user can view officers by warrant status.
public
canOfficersByWarrantStatus(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Context entity
- $optionalArgs : mixed
-
Additional parameters
Return values
boolcanRelease()
Check if user can release an officer. Validates both permission and office access.
public
canRelease(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity to release
- $optionalArgs : mixed
-
[0] = branchId override
Return values
boolcanRequestWarrant()
Check if user can request warrant. Members can request for their own assignments.
public
canRequestWarrant(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity
- $optionalArgs : mixed
-
[0] = branchId override
Return values
boolcanView()
Check if $user can view RolesPermissions
public
canView(KmpIdentityInterface $user, BaseEntity|Table $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity|Table
- $optionalArgs : mixed
Return values
boolcanViewPrivateNotes()
Check if $user can view hidden
public
canViewPrivateNotes(KmpIdentityInterface $user, BaseEntity $entity) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
Return values
boolcanWorkWithAllOfficers()
Check if user can work with all officers across the organization.
public
canWorkWithAllOfficers(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Context entity
- $optionalArgs : mixed
-
Additional parameters
Return values
boolcanWorkWithOfficerDeputies()
Check if user can work with officer deputies.
public
canWorkWithOfficerDeputies(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity
- $optionalArgs : mixed
-
[0] = branchId, [1] = doGrantCheck flag
Return values
boolcanWorkWithOfficerDirectReports()
Check if user can work with direct report officers.
public
canWorkWithOfficerDirectReports(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity
- $optionalArgs : mixed
-
[0] = branchId, [1] = doGrantCheck flag
Return values
boolcanWorkWithOfficerReportingTree()
Check if user can work with officers in their reporting tree.
public
canWorkWithOfficerReportingTree(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
Officer entity
- $optionalArgs : mixed
-
[0] = branchId, [1] = doGrantCheck flag
Return values
boolscopeIndex()
Apply scope for index action.
public
scopeIndex(KmpIdentityInterface $user, mixed $query) : mixed
Parameters
- $user : KmpIdentityInterface
- $query : mixed
_getBranchIdsForPolicy()
Check if $user can view hidden
protected
_getBranchIdsForPolicy(KmpIdentityInterface $user, string $policyMethod) : array<string|int, mixed>|null
Parameters
- $user : KmpIdentityInterface
-
The user.
- $policyMethod : string
Return values
array<string|int, mixed>|null_getPermissions()
Check if $user can view hidden
protected
_getPermissions(KmpIdentityInterface $user) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
Return values
bool_getPolicies()
Check if $user can view hidden
protected
_getPolicies(KmpIdentityInterface $user) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
Return values
bool_hasPolicy()
Check if $user can view hidden
protected
_hasPolicy(KmpIdentityInterface $user, string $policyMethod, BaseEntity|Table $entity[, int|null $branchId = null ][, mixed $grantSource = null ]) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $policyMethod : string
- $entity : BaseEntity|Table
- $branchId : int|null = null
- $grantSource : mixed = null
Return values
bool_hasPolicyForUrl()
Check if $user can view hidden
protected
_hasPolicyForUrl(KmpIdentityInterface $user, string $policyMethod, array<string|int, mixed> $urlProps[, int|null $branchId = null ][, mixed $grantSource = null ]) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $policyMethod : string
- $urlProps : array<string|int, mixed>
- $branchId : int|null = null
- $grantSource : mixed = null
Return values
bool_isSuperUser()
Check if $user is a super user
protected
_isSuperUser(KmpIdentityInterface $user) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
Return values
boolcanManageOfficerMember()
Determine whether the user can manage officer actions for a member.
protected
canManageOfficerMember(KmpIdentityInterface $user, int $memberId) : bool
Allows self or parent-of-minor access.
Parameters
- $user : KmpIdentityInterface
- $memberId : int