diff options
Moved static functionality of Company and JobOffer below the dynamic one
2 files changed, 21 insertions, 13 deletions
| -rw-r--r-- | src/models/Company.php | 14 | ||||
| -rw-r--r-- | src/models/JobOffer.php | 20 |
diff --git a/src/models/Company.php b/src/models/Company.php index 02d073c..0fa72d8 100644 --- a/src/models/Company.php +++ b/src/models/Company.php @@ -2,17 +2,21 @@ include_once("DBModel.php"); class Company extends DBModel { - public const TABLE_NAME = "companies"; - public const TABLE_COLUMNS = array( - "name " . DB::STRING_TYPE, - ); - public string $name; function __construct(string $name) { $this->name = $name; } + /* + * Everything from here is static functionality + */ + + public const TABLE_NAME = "companies"; + public const TABLE_COLUMNS = array( + "name " . DB::STRING_TYPE, + ); + static function __constructStatic() { self::$DB->createTable(self::TABLE_NAME, self::TABLE_COLUMNS); } diff --git a/src/models/JobOffer.php b/src/models/JobOffer.php index 555e7f4..3ec4b77 100644 --- a/src/models/JobOffer.php +++ b/src/models/JobOffer.php @@ -6,14 +6,6 @@ include_once("Company.php"); * Model that contains the required JobOffer properties. It also contains the request methods to the job_offers table. */ class JobOffer extends DBModel { - public const TABLE_NAME = "job_offers"; - public const TABLE_COLUMNS = array( - "title " . DB::STRING_TYPE, - "description " . DB::STRING_TYPE, - "companyId " . DB::INTEGER_TYPE, // Requires a foreign key - "salary " . DB::FLOAT_TYPE, - ); - public string $title; public string $description; public int $companyId; @@ -26,6 +18,18 @@ class JobOffer extends DBModel { $this->salary = $salary; } + /* + * Everything from here is static functionality + */ + + public const TABLE_NAME = "job_offers"; + public const TABLE_COLUMNS = array( + "title " . DB::STRING_TYPE, + "description " . DB::STRING_TYPE, + "companyId " . DB::INTEGER_TYPE, // Requires a foreign key + "salary " . DB::FLOAT_TYPE, + ); + static function __constructStatic() { $foreignKeys = array( DB::genFK("companyId", Company::TABLE_NAME, "id") |
