I am developing a property management database for our company to use in house. The original database was done in PHP/MySQL without using a framework. It works fine, but when a bug is found or a feature needs to be added, it is extremely difficult to work with the existing code base. I'm re-writing the database with CodeIgniter to make it more maintainable. I am relatively new to CodeIgniter 4 and frameworks in general.
I am struggling with the best way to implement inheritance in CodeIgniter 4. In the old database there is a
Property object that handles all of the business logic and database calls for each
Property in the database. Multi-tenant buildings have multiple
Units associated with each
Property stored in a separate table in the database. A
Unit object extends the
Property object and handles the database calls and business logic for each
Unit and also inherits all of the properties and methods from the
Property object.
For example, if I create a new
Unit object, all the database columns from both the
Property table and the
Unit table are used to hydrate the properties for that
Unit object. The
street_num and
street columns from the
Unit table and the
city,
state, and
zip columns from the
Property table are all properties of this
Unit object. So when I echo
$unit->getAddress(), the full address is output.
From what I understand about CodeIgniter 4, Entity classes would be the best way to handle this within the framework. However, Entity classes seem to only represent one row in the database. Can I extend a
Property Entity with a
Unit Entity?