Answer the question
In order to leave comments, you need to log in
Is it acceptable to use inheritance in this situation?
There are two classes for the online store. The first class is called User. It contains variables and methods for defining email, user ID, and so on. The second class is called basket. It contains methods for removing items from the cart, adding items to the cart, and so on. In the basket class, the function for displaying goods from the database takes a user ID as an argument, which is written to the sql query. The user ID can be obtained from a method in the User class. Therefore, I implemented class Basket extends User inheritance. A constructor is created in it, in which variables are written from class User parent::__construct($email, $password). Is it acceptable to use inheritance in this situation?
Answer the question
In order to leave comments, you need to log in
if it seems natural to you that the basket and the user are relatives, then you can.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question