Documentation MyBrickStore

StockModel extends Model
in package

Class StockModel

  • Manages the inventory of lego parts
  • Uses only stockentry to calculate levels (sum of imports and sales)

Table of Contents

Properties

$table  : string

Methods

countLowStockItems()  : int
Counts items below a certain stock threshold for dashboard alerts
countStockItems()  : int
Counts total items matching the current filters for pagination
find()  : mixed
Finds a specific record by its ID.
findAll()  : array<string|int, mixed>|false
Retrieves all records from the associated table.
getAllColors()  : array<string|int, mixed>
Fetches distinct colors for filter dropdowns
getAllItemsForSearch()  : array<string|int, mixed>
Retrieves all items formatted for a search dropdown
getAllShapes()  : array<string|int, mixed>
Fetches distinct shapes for filter dropdowns
getFullStockDetails()  : array<string|int, mixed>
Exports full inventory details for external processing or reporting
getItemReferenceById()  : string|null
Retrieves the text reference (Shape/Color) expected by Java for a given ID.
getPaginatedStock()  : array<string|int, mixed>
Retrieves a paginated list of stock items with optional filters
requete()  : PDOStatement|false
Executes a SQL query (prepared or direct).
updateStock()  : mixed
Records a manual stock adjustment (positive or negative)

Properties

$table

protected string $table = 'Item'

The database table associated with the model.

Methods

countLowStockItems()

Counts items below a certain stock threshold for dashboard alerts

public countLowStockItems([int $threshold = 50 ]) : int
Parameters
$threshold : int = 50

default 50

Return values
int

countStockItems()

Counts total items matching the current filters for pagination

public countStockItems([string|null $shapeFilter = null ][, string|null $colorFilter = null ][, string $statusFilter = 'all' ]) : int
Parameters
$shapeFilter : string|null = null
$colorFilter : string|null = null
$statusFilter : string = 'all'
Return values
int

total count

find()

Finds a specific record by its ID.

public find(int $id) : mixed
Parameters
$id : int

The record identifier.

Return values
mixed

The record object or false if not found.

findAll()

Retrieves all records from the associated table.

public findAll() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

List of records.

getAllColors()

Fetches distinct colors for filter dropdowns

public getAllColors() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllItemsForSearch()

Retrieves all items formatted for a search dropdown

public getAllItemsForSearch() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllShapes()

Fetches distinct shapes for filter dropdowns

public getAllShapes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFullStockDetails()

Exports full inventory details for external processing or reporting

public getFullStockDetails() : array<string|int, mixed>
Return values
array<string|int, mixed>

getItemReferenceById()

Retrieves the text reference (Shape/Color) expected by Java for a given ID.

public getItemReferenceById(int $idItem) : string|null
Parameters
$idItem : int
Return values
string|null

Format "ShapeName/HexColor" (ex: "2-2/c9cae2")

getPaginatedStock()

Retrieves a paginated list of stock items with optional filters

public getPaginatedStock(int $limit, int $page[, string|null $shapeFilter = null ][, string|null $colorFilter = null ][, string $statusFilter = 'all' ]) : array<string|int, mixed>
Parameters
$limit : int

number of items per page

$page : int

current page number

$shapeFilter : string|null = null

filter by shape name

$colorFilter : string|null = null

filter by color name

$statusFilter : string = 'all'

filter by stock level ('all', 'low', 'critical')

Return values
array<string|int, mixed>

list of items

requete()

Executes a SQL query (prepared or direct).

public requete(string $sql[, array<string|int, mixed>|null $attributs = null ]) : PDOStatement|false
Parameters
$sql : string

The SQL query string.

$attributs : array<string|int, mixed>|null = null

Optional parameters for prepared statements.

Return values
PDOStatement|false

The result statement.

updateStock()

Records a manual stock adjustment (positive or negative)

public updateStock(int $itemId, int $quantity) : mixed
Parameters
$itemId : int
$quantity : int

        
On this page

Search results