public function getByJobId($id)
 {
     $pdo = Config::getInstance()->get('db.pdo');
     $stmt = $pdo->prepare('SELECT * FROM applications WHERE job_id = :id');
     $stmt->execute(['id' => $id]);
     $_applications = $stmt->fetchAll();
     $applications = [];
     foreach ($_applications as $_application) {
         $a = new Application();
         $a->fill($_application);
         $applications[] = $a;
     }
     return $applications;
 }
Example #2
0
 public function postJob($req)
 {
     $uploaded = !(!file_exists($_FILES['cv']['tmp_name']) || !is_uploaded_file($_FILES['cv']['tmp_name']));
     if ($uploaded) {
         $a = new Application();
         $a->fill($_POST);
         $a->job_id = $req->id;
         // Upload with random base name to avoid collision
         $target_folder = JF_PROJECT_ROOT . '/public/uploads/';
         $target_file = time() . rand() . basename($_FILES['cv']['name']);
         move_uploaded_file($_FILES['cv']['tmp_name'], $target_folder . $target_file);
         $a->cv_path = $target_file;
         $result = $a->save();
     } else {
         $result = false;
     }
     if ($result) {
         $this->service->flash('Your application was saved.', 'success');
     } else {
         $this->service->flash('We are having problems saving your application. Please try again later.', 'alert');
     }
     return $this->service->back();
 }