Location
in package
The Location class provides methods to interact with the locations in a database.
It includes functionalities to retrieve, create, and update location records, and supports operations for administrative usage.
Table of Contents
Properties
Methods
- __construct() : mixed
- createByAdmin() : void
- Create a location (admin).
- getAll() : array<int, array<string, mixed>>
- Get all locations by status.
- getByCode() : array<string, mixed>
- Get a location by code.
- updateByCode() : void
- Update location by code (admin).
Properties
$mySql
protected
MySql
$mySql
Methods
__construct()
public
__construct(MySql $mySql) : mixed
Parameters
- $mySql : MySql
createByAdmin()
Create a location (admin).
public
createByAdmin(array<string, mixed> $data) : void
Expects in $data:
- location_code (string, required)
- location_name (string, required)
- reference_code (string|null)
- sort_order (int|null)
- status (int, required; default 1)
- createdby (string, required)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>
getAll()
Get all locations 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 location by code.
public
getByCode(string $locationCode) : array<string, mixed>
Parameters
- $locationCode : string
Return values
array<string, mixed>updateByCode()
Update location by code (admin).
public
updateByCode(array<string, mixed> $data) : void
Behaviour for reference_code:
- If key not present in $data → keep existing reference_id / reference_code.
- If present and empty → set reference_id / reference_code to NULL.
- If present and non-empty → resolve id by code and update both fields.
Expects in $data:
- location_code (string, required)
- location_name (string|null)
- reference_code (string|null, presence matters)
- sort_order (int|null)
- status (int|null)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>