-
Notifications
You must be signed in to change notification settings - Fork 8
Products.php
- This document provides an overview of the file's structure and functionality.
- Products.php handles managing individual products, their images, and their details.
-
Products.phpDocumentation- Overview
- Table of Contents
- Properties
- Methods
-
Product Model
__construct()addProduct()addProductCompatibility()addProductImage()addProductSlot()deleteProduct()deleteProductImage()getAllCompatibleProducts()getAllProducts()getCategories()getProductByID()getProductByName()getProductCompatibility()getProductImages()getProductSlots()updateProductDetail()
-
Product
__construct()getProductID()setProductID()getName()setName()getPrice()setPrice()getStock()setStock()getDescription()setDescription()getCategoryID()setCategoryID()getCategoryName()setCategoryName()getMainImage()setMainImage()getOtherImages()setOtherImages()getCreatedAt()setCreatedAt()getUpdatedAt()setUpdatedAt()getProductReviews()setProductReviews()
- Product Review
- Products.php contains a single property
- Products.php contains a variety of methods used to provide functionality to the website.
ProductModel constructor.
Parameters
-
$database : PDO- The database connection.
Return N/A
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.
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.
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
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.
Delete a product.
Parameters
-
$productID : int- The unique identifier of the product.
Return bool
- True if the deletion is successful, false otherwise.
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.
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.
Retrieve all products.
Parameters N/A
Return array<string|int, mixed>|null
- An array of product details or null if no products found.
Get all categories.
Parameters N/A
Return array<string|int, mixed>|null
- An array of category details or null if not found.
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.
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.
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.
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.
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.
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.
Construct a new Product object by providing an associative array of product details.
Parameters
$productDetails : array- array of the product details
Return N/A
Get the unique identifier of the product.
Parameters N/A
Return int
- The unique identifier of the product.
Set the unique identifier of the product.
Parameters
-
$productID : int- The unique identifier of the product.
Return N/A
Get the name of the product.
Parameters N/A
Return string
- The name of the product.
Set the name of the product.
Parameters
-
$name : string- The name of the product.
Return N/A
Get the price of the product.
Parameters N/A
Return float
- The price of the product.
Set the price of the product.
Parameters
-
$price : float- The price of the product.
Return N/A
Get the stock of the product.
Parameters N/A
Return int
- The stock of the product.
Set the stock of the product.
Parameters
-
$stock : int- The stock of the product.
Return N/A
Get the description of the product.
Parameters N/A
Return string
- The description of the product.
Set the description of the product.
Parameters
-
$description : string- The description of the product.
Return N/A
Get the category ID of the product.
Parameters N/A
Return int
- The category ID of the product.
Set the category ID of the product.
Parameters
-
$categoryID : int- The category ID of the product.
Return N/A
Get the category name of the product.
Parameters N/A
Return string
- The category name of the product.
Set the category name of the product.
Parameters
-
$categoryName : string- The category name of the product.
Return N/A
Get the main image of the product.
Parameters N/A
Return string
- The main image of the product.
Set the main image of the product.
Parameters
-
$mainImage : string- The main image of the product.
Return N/A
Get the other images of the product.
Parameters N/A
Return array
- The other images of the product.
Set the other images of the product.
Parameters
-
$otherImages : array- The other images of the product.
Return N/A
Get the date and time the product was created.
Parameters N/A
Return string
- The date and time the product was created.
Set the date and time the product was created.
Parameters
-
$createdAt : string- The date and time the product was created.
Return Void
Get the date and time the product was last updated.
Parameters N/A
Return string
- The date and time the product was last updated.
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
Get the reviews associated with the product.
Parameters N/A
Return array
- An array of ProductReviews.
Sets the reviews associated with the product.
Parameters
-
$reviews : array- An array of ProductReviews.
Return N/A
Create a ProductReview object by providing an associative array of productReview details.
Parameters
-
$reviewDetails : array- array of review details
Return N/A
Get the unique identifier of the product.
Parameters N/A
Return int
- The unique identifier of the product.
Set the unique identifier of the product.
Parameters
-
$productID : int- The unique identifier of the product.
Return N/A
Gets the customerID of the productReview.
Parameters N/A
Return int
- The unique identifier of the customer.
Sets the customerID of the productReview.
Parameters
-
$customerID : int- The unique identifier of the customer.
Return N/A
Gets the customer name of the productReview.
Parameters N/A
Return int
- The username of the customer.
Sets the customerName of the productReview.
Parameters
-
$customerName : int- The username of the customer.
Return N/A
Gets the rating of the productReview.
Parameters N/A
Return int
- The rating value.
Sets the rating of the productReview.
Parameters
-
$rating : int- The rating value.
Return N/A
Gets the review of the productReview.
Parameters N/A
Return string
- The review.
Sets the review of the productReview.
Parameters
-
$review : string- The review.
Return N/A
Get the date and time the productReview was created.
Parameters N/A
Return string
- The date and time the productReview was created.
Set the date and time the productReview was created.
Parameters
-
$createdAt : string- The date and time the productReview was created.
Return Void
Get the date and time the productReview was last updated.
Parameters N/A
Return string
- The date and time the productReview was last updated.
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