From da1cf823d75923594b926d0c46956f385b4ed987 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 1 Apr 2021 12:23:30 +0300 Subject: Job offers company is now a foreign key to the company model --- src/models/JobOffer.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/models/JobOffer.php') diff --git a/src/models/JobOffer.php b/src/models/JobOffer.php index 4a53b8d..555e7f4 100644 --- a/src/models/JobOffer.php +++ b/src/models/JobOffer.php @@ -1,25 +1,36 @@ title = $title; $this->description = $description; - $this->company = $company; + $this->companyId = $companyId; $this->salary = $salary; + } - self::$DB->createTable(self::TABLE_NAME, self::TABLE_COLUMNS); + static function __constructStatic() { + $foreignKeys = array( + DB::genFK("companyId", Company::TABLE_NAME, "id") + ); + self::$DB->createTable(self::TABLE_NAME, self::TABLE_COLUMNS, $foreignKeys); } /* Create */ @@ -74,3 +85,5 @@ class JobOffer extends DBModel { self::$DB->deleteById(self::TABLE_NAME, $id); } } + +JobOffer::__constructStatic(); -- cgit v1.3.1-26-gb76a