Trolleys

Models

Overview of WHAM Trolley Models

Wham Services offers a variety of trolley models to suit different needs, including QuickTrolley.php, Trolley.php, TrolleyItem.php, and TrolleyLine.php. Each model is designed to deliver specific functionalities and efficiencies for diverse operational requirements.


The Trolley module fires the following models.

Class NameModels
Toolstation\Trolleys\Models\QuickTrolleyThe QuickTrolley class is an Eloquent model representing trolleys, linked to the web_trolley_prints table in Toolstation.
Toolstation\Trolleys\Models\TrolleyThe Trolley class is an Eloquent model in the Toolstation\Trolleys\Models namespace, representing trolley records in the Toolstation application.
Toolstation\Trolleys\Models\TrolleyItemThe TrolleyItem class is an Eloquent model in Toolstation\Trolleys\Models, representing items in trolleys and interacting with the web_trolleys table.
Toolstation\Trolleys\ModelsTrolleyLineThe TrolleyLine class represents a line item in a trolley, encapsulating the quantity and pricing details of a product within the trolley.

QuickTrolley Model

The QuickTrolley class is an Eloquent model in the Toolstation\Trolleys\Models namespace, representing trolleys in the Toolstation application. It interacts with the web_trolley_prints table in the database.

Data

  • Namespace: Toolstation\Trolleys\Models
  • Table: web_trolley_prints
  • Primary Key: wtp_ref
  • Connection: web
  • Timestamps: None
  • Field Prefix: wtp
  • Fillable Attributes:
    • sessionId
    • ref
    • trolley
    • dateTime
    • label
  • Date Attributes:
    • wtp_ts
  • Accessors:
    • getSessionIdAttribute: Returns the session ID.
    • getDateTimeAttribute: Returns the timestamp.
    • getRefAttribute: Returns the reference value.
    • getLabelAttribute: Returns the label or formatted timestamp.
    • getTrolleyAttribute: Returns the unserialized trolley data.
  • Mutators:
    • setSessionIdAttribute: Sets the session ID.
    • setDateTimeAttribute: Sets the timestamp.
    • setRefAttribute: Sets the reference value.
    • setTrolleyAttribute: Serializes and sets the trolley data.
    • setLabelAttribute: Sets the label.
  • Relationships:
    • customer(): BelongsTo - The customer associated with the trolley.

Note: The model does not use timestamps and treats its primary key as a non-incrementing string.


Trolley Model

The Trolley class is an Eloquent model in the Toolstation\Trolleys\Models namespace, representing trolley records in the Toolstation application.

Data

  • Namespace: Toolstation\Trolleys\Models
  • Table: (Specify table name if different from default convention)
  • Primary Key: (Specify primary key if different from default convention)
  • Connection: (Specify database connection if different from default)
  • Timestamps: (Specify if timestamps are used or not)

Notes

  • This model currently does not have any defined methods or attributes. It serves as a base for future extension and customization.

TrolleyItem Model

The TrolleyItem class is an Eloquent model in the Toolstation\Trolleys\Models namespace. It represents individual items within trolleys in the Toolstation application and interacts with the web_trolleys table in the database.

Data

  • Namespace: Toolstation\Trolleys\Models
  • Table: web_trolleys
  • Primary Key: None (uses a non-incrementing, string-based key)
  • Connection: web
  • Timestamps: None
  • Field Prefix: wtr
  • Fillable Attributes:
    • trolleyId
    • dateTime
    • productId
    • freeItems
    • quantity
    • channel
  • Date Attributes:
    • wtr_ts

Accessors:

  • getTrolleyIdAttribute: Returns the trolley ID.
  • getDateTimeAttribute: Returns the timestamp.
  • getProductIdAttribute: Returns the product ID.
  • getQuantityAttribute: Returns the quantity.
  • getFreeItemsAttribute: Returns the free items count.
  • getChannelAttribute: Returns the channel.

Mutators:

  • setTrolleyIdAttribute: Sets the trolley ID.
  • setDateTimeAttribute: Sets the timestamp.
  • setProductIdAttribute: Sets the product ID.
  • setQuantityAttribute: Sets the quantity.
  • setFreeItemsAttribute: Sets the free items count.
  • setChannelAttribute: Sets the channel.

Note: The model does not use default timestamps and handles non-incrementing string keys.


TrolleyLine Class

The TrolleyLine class represents a line item in a trolley, encapsulating the quantity and pricing details of a product within the trolley.

Data

  • Namespace: Toolstation\Trolleys\Models
  • Dependencies: Product class from Toolstation\Products\Models

Properties

  • $quantity: The quantity of the product in the trolley.
  • $prices: An array containing the current price details of the product.

Constructor

  • __construct(Product $product, int $quantity = 1): Initializes a TrolleyLine instance with a Product object and an optional quantity (default is 1).

Methods

  • addQuantity($add): Adds a specified number to the existing quantity.
  • subQuantity($sub): Subtracts a specified number from the existing quantity.
  • getQuantity(): Returns the current quantity.
  • setQuantity($quantity): Sets the quantity, ensuring it is not negative.
  • linePriceNet(bool $pence = false, bool $exact = false): Calculates the net price of the line item, optionally in pence and with exact rounding.
  • linePriceGross(bool $pence = false): Calculates the gross price of the line item, optionally in pence.
  • linePriceVat(bool $pence = false, bool $exact = false): Calculates the VAT amount for the line item, optionally in pence and with exact rounding.

Notes

  • The class uses the getCurrentPrice() method from the Product class to retrieve the current pricing information.
  • VAT calculation is handled by the getVat function, which is assumed to be defined elsewhere in the application.
  • Price calculations can be adjusted to return values in pence or as floating-point numbers.

Usage

This class is used to manage individual product lines within a trolley, allowing for dynamic quantity adjustments and detailed pricing calculations, including VAT.



Copyright © 2026