Unit
in package
Represents a Unit entity and provides various methods to interact with the database for unit-related operations.
Table of Contents
Properties
Methods
- __construct() : mixed
- createByAdmin() : void
- Create a new unit (admin).
- getAll() : array<int, array<string, mixed>>
- Get all units filtered by status.
- getByCode() : array<string, mixed>
- Get a unit by its code.
- updateByCode() : void
- Update a unit by code (admin).
Properties
$mySql
protected
MySql
$mySql
Methods
__construct()
public
__construct(MySql $mySql) : mixed
Parameters
- $mySql : MySql
createByAdmin()
Create a new unit (admin).
public
createByAdmin(array<string, mixed> $data) : void
Expects in $data:
- unit_code (string, required)
- unit_name (string, required)
- unit_display (string|null)
- reference_code (string, required – must exist in reference table)
- sort_order (int|null)
- status (int, required)
- createdby (string, required)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>
getAll()
Get all units filtered by status.
public
getAll(array<string|int, int> $statuses) : array<int, array<string, mixed>>
Parameters
- $statuses : array<string|int, int>
Return values
array<int, array<string, mixed>>getByCode()
Get a unit by its code.
public
getByCode(string $unitCode) : array<string, mixed>
Parameters
- $unitCode : string
Return values
array<string, mixed>updateByCode()
Update a unit by code (admin).
public
updateByCode(array<string, mixed> $data) : void
Expects in $data:
- unit_code (string, required)
- unit_name (string|null)
- unit_display (string|null)
- reference_code (string, required – will be resolved to reference_id)
- sort_order (int|null)
- status (int|null)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>