Example #1
0
 public function postEdit($req)
 {
     $j = new Job();
     $j->fill($_POST);
     $j->id = $req->id;
     $result = $j->save();
     if ($result) {
         $this->service->flash('The job was edited.', 'success');
     } else {
         $this->service->flash('Can\'t edit the job.', 'alert');
     }
     return $this->service->back();
 }
Example #2
0
 public function filter($name, $category_id, $lat, $lng, $radius)
 {
     $pdo = Config::getInstance()->get('db.pdo');
     $stmt = $pdo->prepare('SELECT jobs.*, categories.name category_name FROM jobs JOIN categories ON categories.id = jobs.category_id WHERE jobs.name LIKE :name AND jobs.category_id = :category_id');
     $stmt->execute(['name' => '%' . $name . '%', 'category_id' => $category_id]);
     $_jobs = $stmt->fetchAll();
     $jobs = [];
     foreach ($_jobs as $_job) {
         if ($this->distance($lat, $lng, $_job['lat'], $_job['lng']) <= $radius) {
             $j = new Job();
             $j->fill($_job);
             $c = new Category();
             $c->id = $_job['category_id'];
             $c->name = $_job['category_name'];
             $j->setCategory($c);
             $jobs[] = $j;
         }
     }
     return $jobs;
 }