From d68eb37381d8ef8271330dfe373e171673317695 Mon Sep 17 00:00:00 2001 From: Joshua Perry <45966243+jpez-development@users.noreply.github.com> Date: Mon, 23 Jan 2023 16:44:56 +0000 Subject: [PATCH] improved vars --- jobs/controllers/Jobs.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/jobs/controllers/Jobs.php b/jobs/controllers/Jobs.php index facdb4d..e9d1c74 100644 --- a/jobs/controllers/Jobs.php +++ b/jobs/controllers/Jobs.php @@ -3,16 +3,18 @@ namespace jobs\controllers; class Jobs { private $jobsTable; private $catsTable; + private $vars = []; public function __construct(\CSY2028\DatabaseTable $jobsTable, \CSY2028\DatabaseTable $catsTable) { $this->jobsTable = $jobsTable; $this->catsTable = $catsTable; + $this->vars['cats'] = $this->catsTable->findAll(); } public function home() { return ['template' => 'home.html.php', 'title' => 'Jo\'s Jobs- Home', - 'vars' => ['cats' => $this->catsTable->findAll()] + 'vars' => $this->vars ]; } @@ -22,20 +24,27 @@ class Jobs { return $this->notFound(); } else { + $this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id); + $this->vars['heading'] = $cat[0]->name; return ['template' => 'category.html.php', 'title' => 'Jo\'s Jobs- '. $_GET['page'], - 'vars' => ['jobs' => $this->jobsTable->find('categoryId', $cat[0]->id), - 'cats' => $this->catsTable->findAll(), - 'heading' => $cat[0]->name] - ]; + 'vars' => $this->vars + ]; } } + public function about() { + return ['template' => 'about.html.php', + 'title' => 'Jo\'s Jobs- About us', + 'vars' => $this->vars + ]; + } + public function notFound() { return ['template' => 'notFound.html.php', 'title' => 'Jo\'s Jobs- 404 Not Found', - 'vars' => [] - ]; + 'vars' => $this->vars + ]; } } ?> \ No newline at end of file