public function action_edit($id = null) { $location = Model_Location::find($id); $val = Model_Location::validate('edit'); if ($val->run()) { $location->name = Input::post('name'); $location->can_sell = Input::post('can_sell'); if ($location->save()) { Session::set_flash('success', e('Updated location #' . $id)); Response::redirect('admin/locations'); } else { Session::set_flash('error', e('Could not update location #' . $id)); } } else { if (Input::method() == 'POST') { $location->name = $val->validated('name'); $location->can_sell = $val->validated('can_sell'); Session::set_flash('error', $val->error()); } $this->template->set_global('location', $location, false); } $this->template->title = "Locations"; $this->template->content = View::forge('admin/locations/edit'); }
public function action_locations($id = null) { $pass = Model_Pass::find($id); if (Input::method() == 'POST') { $val = Model_Location::validate('create'); if ($val->run()) { $location = Model_Location::forge(array('latitude' => \Fuel\Core\Input::post('latitude'), 'longitude' => \Fuel\Core\Input::post('longitude'), 'altitude' => \Fuel\Core\Input::post('altitude', null), 'relevant_text' => \Fuel\Core\Input::post('relevant_text', null))); $pass->locations[] = $location; if ($location and $pass->save()) { Session::set_flash('success', e('Added location #' . $location->id . '.')); \Fuel\Core\Response::redirect('admin/pass/locations/' . $id); return; } else { Session::set_flash('error', e('Could not save location.')); } } else { Session::set_flash('error', $val->error()); } } $this->template->set_global('pass', $pass, false); $this->template->title = "Pass Locations"; $this->template->content = View::forge('admin/pass/locations'); }