function index($config, $parameters) { loadModel('models/Subjects'); $subjects = getAllSubjects($config); if ($subjects['status']) { return $subjects; } return ['status' => false, 'message' => 'An error occured while trying to retrieve Subjects records.', 'code' => 500]; }
function add($config, $parameters) { loadModel('models/Subjects'); loadModel('models/Students'); $subjects = getAllSubjects($config); if (!$subjects['status']) { $subjects['subjects'] = []; } if ('POST' == getRequestMethod()) { $result = addStudent($config, $_POST); $_SESSION['addStatus'] = $result['status']; $_SESSION['addStatusMessage'] = $result['message']; header('Location: /students'); } return ['status' => true, 'message' => 'An error occured while trying to retrieve Student records.', 'subjects' => $subjects['subjects']]; }