StaffService
in package
Service for managing client staff accounts and permissions.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Initialize the staff service.
- createStaff() : array<string|int, mixed>
- Create a new staff member.
- deleteStaff() : array<string|int, mixed>
- Delete (deactivate) a staff member.
- getDefaultPermissions() : array<string|int, mixed>
- Get default permissions for a role.
- hasPermission() : bool
- Check if a user has a specific permission.
- resetPassword() : array<string|int, mixed>
- Reset a staff member's password.
- updateStaff() : array<string|int, mixed>
- Update a staff member.
Properties
$userModel
private
User
$userModel
User model
Methods
__construct()
Initialize the staff service.
public
__construct() : mixed
createStaff()
Create a new staff member.
public
createStaff(int $businessId, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $businessId : int
-
Business ID
- $data : array<string|int, mixed>
-
Staff data (name, email, password, role, phone, permissions)
Return values
array<string|int, mixed> —Result with keys: success, user_id, error
deleteStaff()
Delete (deactivate) a staff member.
public
deleteStaff(int $id, int $businessId) : array<string|int, mixed>
Parameters
- $id : int
-
User ID
- $businessId : int
-
Business ID
Return values
array<string|int, mixed> —Result with keys: success, error
getDefaultPermissions()
Get default permissions for a role.
public
getDefaultPermissions(string $role) : array<string|int, mixed>
Parameters
- $role : string
-
User role
Return values
array<string|int, mixed>hasPermission()
Check if a user has a specific permission.
public
hasPermission(array<string|int, mixed> $user, string $permission) : bool
Hierarchy: owner > staff_admin > manager > staff. Owners bypass all permission checks. Staff admins have all staff permissions plus staff_manage.
Parameters
- $user : array<string|int, mixed>
-
User record
- $permission : string
-
Permission key
Return values
boolresetPassword()
Reset a staff member's password.
public
resetPassword(int $id, int $businessId, string $newPassword) : array<string|int, mixed>
Parameters
- $id : int
-
User ID
- $businessId : int
-
Business ID
- $newPassword : string
-
New password
Return values
array<string|int, mixed> —Result with keys: success, error
updateStaff()
Update a staff member.
public
updateStaff(int $id, int $businessId, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $id : int
-
User ID
- $businessId : int
-
Business ID (for ownership check)
- $data : array<string|int, mixed>
-
Updated data
Return values
array<string|int, mixed> —Result with keys: success, error