Summary Files Commits Branches @commit @diff @stats
path: root / src / controllers / DashboardController.php
blob: 59c109002826818046a843a624415b1bfb540776 (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
33
34
<?php
include_once('controllers/BaseController.php');
include_once('models/JobOffer.php');
include_once('models/Company.php');
include_once('controllers/EditOfferController.php');

class DashboardController extends BaseController {
	public static $companies = array();

	public static function get() {
		$jobs = JobOffer::getAllFromDB();
		foreach(Company::getAllFromDB() as $company) {
			self::$companies[$company->id] = $company->name;
		}
		include('views/dashboard.php');
	}

	public static function post() {
		// Forms can only send POST or GET requests.
		// EditOfferController doesn't have it's own URI, so we can't send a request.
		// We also can't just invoke it, because that means manually changing the server's request method.
		switch($_POST['_method']) {
			case 'get':
				EditOfferController::get();
				break;
			case 'put':
				EditOfferController::put();
				break;
			case 'delete':
				EditOfferController::delete();
				break;
		}
	}
}