Skip to content
Reece Edwards edited this page Apr 15, 2024 · 2 revisions

Products.php Documentation

Overview

  • This document provides an overview of the file's structure and functionality.
  • Products.php handles managing individual products, their images, and their details.

Table of Contents

Properties

  • Products.php contains a single property

$database

Methods

  • Products.php contains a variety of methods used to provide functionality to the website.

Product Model

__construct()

ProductModel constructor.

Parameters

  • $database : PDO
    • The database connection.

Return N/A

addProduct()

Add a new product.

Parameters

  • $productData : array<string|int, mixed>
    • The product data including name, price, and stock.

Return array<string|int, mixed>|null

  • The added product details or null if adding fails.

addProductCompatibility()

Add compatibility for a product.

Parameters

  • $productID : int

    • The unique identifier of the product.
  • $compatibilityID : int

    • The unique identifier of the compatibility type.
  • $slotType : string

    • The type of slot compatibility (e.g., USB, PCIe).

Return bool

  • True if the addition is successful, false otherwise.

addProductImage()

Add an image for a product.

Parameters

  • $productID : int

    • The unique identifier of the product.
  • $imageName : string

    • The name of the image.

Return N/A

addProductSlot()

Add slot type for a product.

Parameters

  • $productID : int

    • The unique identifier of the product.
  • $slotType : string

    • The type of slot compatibility (e.g., USB, PCIe).

Return bool

  • True if the addition is successful, false otherwise.

deleteProduct()

Delete a product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return bool

  • True if the deletion is successful, false otherwise.

deleteProductImage()

Delete an image for a product.

Parameters

  • $productID : int

    • The unique identifier of the product.
  • $imageName : string

    • The name of the image file.

Return bool

  • True if the deletion is successful, false otherwise.

getAllCompatibleProducts()

Retrieve all products that are compatible with a product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return array<string|int, mixed>|null

  • An array of compatible products or null if not found.

getAllProducts()

Retrieve all products.

Parameters N/A

Return array<string|int, mixed>|null

  • An array of product details or null if no products found.

getCategories()

Get all categories.

Parameters N/A

Return array<string|int, mixed>|null

  • An array of category details or null if not found.

getProductByID()

Retrieve product details by ID.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return array<string|int, mixed>|null

  • The product details or null if not found.

getProductByName()

Retrieve product details by name.

Parameters

  • $productName : string
    • The name of the product.

Return array<string|int, mixed>|null

  • The product details or null if not found.

getProductCompatibility()

Retrieve compatibility types for a product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return array<string|int, mixed>|null

  • An array of compatibility types or null if not found.

getProductImages()

Retrieve all images for a product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return array<string|int, mixed>|null

  • An array of image details or null if not found.

getProductSlots()

Retrieve slot types for a product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return array<string|int, mixed>|null

  • An array of slot types or null if not found.

updateProductDetail()

Update a product's details.

Parameters

  • $productID : int

    • The unique identifier of the product.
  • $field : string

    • The field to update.
  • $value : string|int

    • The new value.

Return bool

  • True if the update is successful, false otherwise.

Product

__construct()

Construct a new Product object by providing an associative array of product details.

Parameters

  • $productDetails : array
  • array of the product details

Return N/A

getProductID()

Get the unique identifier of the product.

Parameters N/A

Return int

  • The unique identifier of the product.

setProductID()

Set the unique identifier of the product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return N/A

getName()

Get the name of the product.

Parameters N/A

Return string

  • The name of the product.

setName()

Set the name of the product.

Parameters

  • $name : string
    • The name of the product.

Return N/A

getPrice()

Get the price of the product.

Parameters N/A

Return float

  • The price of the product.

setPrice()

Set the price of the product.

Parameters

  • $price : float
    • The price of the product.

Return N/A

getStock()

Get the stock of the product.

Parameters N/A

Return int

  • The stock of the product.

setStock()

Set the stock of the product.

Parameters

  • $stock : int
    • The stock of the product.

Return N/A

getDescription()

Get the description of the product.

Parameters N/A

Return string

  • The description of the product.

setDescription()

Set the description of the product.

Parameters

  • $description : string
    • The description of the product.

Return N/A

getCategoryID()

Get the category ID of the product.

Parameters N/A

Return int

  • The category ID of the product.

setCategoryID()

Set the category ID of the product.

Parameters

  • $categoryID : int
    • The category ID of the product.

Return N/A

getCategoryName()

Get the category name of the product.

Parameters N/A

Return string

  • The category name of the product.

setCategoryName()

Set the category name of the product.

Parameters

  • $categoryName : string
    • The category name of the product.

Return N/A

getMainImage()

Get the main image of the product.

Parameters N/A

Return string

  • The main image of the product.

setMainImage()

Set the main image of the product.

Parameters

  • $mainImage : string
    • The main image of the product.

Return N/A

getOtherImages()

Get the other images of the product.

Parameters N/A

Return array

  • The other images of the product.

setOtherImages()

Set the other images of the product.

Parameters

  • $otherImages : array
    • The other images of the product.

Return N/A

getCreatedAt()

Get the date and time the product was created.

Parameters N/A

Return string

  • The date and time the product was created.

setCreatedAt()

Set the date and time the product was created.

Parameters

  • $createdAt : string
    • The date and time the product was created.

Return Void

getUpdatedAt()

Get the date and time the product was last updated.

Parameters N/A

Return string

  • The date and time the product was last updated.

setUpdatedAt()

Set the date and time the product was last updated.

Parameters

  • $updatedAt : string
    • The date and time the product was last updated.

Return N/A

getProductReviews()

Get the reviews associated with the product.

Parameters N/A

Return array

  • An array of ProductReviews.

setProductReviews()

Sets the reviews associated with the product.

Parameters

  • $reviews : array
    • An array of ProductReviews.

Return N/A

Product Review

__construct()

Create a ProductReview object by providing an associative array of productReview details.

Parameters

  • $reviewDetails : array
    • array of review details

Return N/A

getProductID()

Get the unique identifier of the product.

Parameters N/A

Return int

  • The unique identifier of the product.

setProductID()

Set the unique identifier of the product.

Parameters

  • $productID : int
    • The unique identifier of the product.

Return N/A

getCustomerID()

Gets the customerID of the productReview.

Parameters N/A

Return int

  • The unique identifier of the customer.

setCustomerID()

Sets the customerID of the productReview.

Parameters

  • $customerID : int
    • The unique identifier of the customer.

Return N/A

getCustomerName()

Gets the customer name of the productReview.

Parameters N/A

Return int

  • The username of the customer.

setCustomerName()

Sets the customerName of the productReview.

Parameters

  • $customerName : int
    • The username of the customer.

Return N/A

getRating()

Gets the rating of the productReview.

Parameters N/A

Return int

  • The rating value.

setRating()

Sets the rating of the productReview.

Parameters

  • $rating : int
    • The rating value.

Return N/A

getReview()

Gets the review of the productReview.

Parameters N/A

Return string

  • The review.

setReview()

Sets the review of the productReview.

Parameters

  • $review : string
    • The review.

Return N/A

getCreatedAt()

Get the date and time the productReview was created.

Parameters N/A

Return string

  • The date and time the productReview was created.

setCreatedAt()

Set the date and time the productReview was created.

Parameters

  • $createdAt : string
    • The date and time the productReview was created.

Return Void

getUpdatedAt()

Get the date and time the productReview was last updated.

Parameters N/A

Return string

  • The date and time the productReview was last updated.

setUpdatedAt()

Set the date and time the productReview was last updated.

Parameters

  • $updatedAt : string
    • The date and time the productReview was last updated.

Return N/A

Clone this wiki locally