Summary Files Commits Branches @commit @diff @stats
path: root / src / models / JobOffer.php
blob: 7603211dd47deff454f85fc4cd517466563c7ae4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include_once("DBModel.php");

class JobOffer extends DBModel {
	public const TABLE_NAME = "job_offers";
	public const TABLE_COLUMNS = array("title " . DB::STRING_TYPE, "description " . DB::STRING_TYPE, "company " . DB::STRING_TYPE, "salary " . DB::FLOAT_TYPE);

	public string $title;
	public string $description;
	public string $company;
	public float $salary;

	function __construct(string $title, string $description, string $company, float $salary) {
		$this->title = $title;
		$this->description = $description;
		$this->company = $company;
		$this->salary = $salary;

		self::$DB->createTable(self::TABLE_NAME, self::TABLE_COLUMNS);
	}

	/**
	 * @return JobOffer[]
	 */
	static function getAll() {
		return self::$DB->getAllValues(self::TABLE_NAME);
	}

	static function insertInDB(JobOffer $jb) {
		self::$DB->insertValue(self::TABLE_NAME, $jb->title, $jb->description, $jb->company, $jb->salary);
	}
}