Exemplo n.º 1
0
 /**
  * Create a station within a country
  *
  * @access public
  * @param  int $id (country id)
  * @return void
  */
 public function create()
 {
     $station = new Station();
     if ($this->input->post("device_id")) {
         $station->populate($this->input->post());
         if ($station->save()) {
             Notification::set(Stations::SUCCESS, "The station has been added");
             redirect("/stations/");
         }
     }
     $this->data["regions"] = (new Region())->load();
     $this->data["station"] = $station;
     $this->load->view("stations/create", $this->data);
 }
Exemplo n.º 2
0
 public function findByUserId($userId)
 {
     if (!is_numeric($userId)) {
         throw new InvalidArgumentException("Invalid param(s) supplied");
     }
     $this->db->select("main.*");
     $this->db->from(self::TABLE . " as main");
     $this->db->where("main.active", 1);
     $this->db->join("users_stations us", "us.user_id = '" . $userId . "' " . "AND us.station_id = main.id");
     $get = $this->db->get()->result_array();
     $result = [];
     if (!is_null($get)) {
         foreach ($get as $row) {
             $object = new Station();
             $result[] = $object->populate($row);
         }
     }
     return $result;
 }