public function action_delete($id = null) { if ($city = \Model\City::find($id)) { $city->delete(); \Session::set_flash('success', 'Deleted city #' . $id); } else { \Session::set_flash('error', 'Could not delete city #' . $id); } \Response::redirect('admin/city'); }
public function action_edit($id = null) { is_null($id) and \Response::redirect('job'); $job = \Model\Job::find($id); if (\Input::method() == 'POST') { $val = \Model\Job::validate('edit'); if ($val->run()) { $job->title = \Input::post('title'); $job->intro = \Input::post('intro'); $job->overview = \Input::post('overview'); $job->main_tasks = \Input::post('main_tasks'); $job->profile = \Input::post('profile'); $job->we_offer = \Input::post('we_offer'); $job->place_of_work = \Input::post('place_of_work'); $job->start_date = \Input::post('start_date'); $job->type_of_contract = \Input::post('type_of_contract'); $job->activity_rate = \Input::post('activity_rate'); $job->reference = \Input::post('reference'); $job->more_info = \Input::post('more_info'); $job->open = \Input::post('open'); if ($job->save()) { \Session::set_flash('success', 'Updated job #' . $id); \Response::redirect('admin/job'); } else { \Session::set_flash('error', 'Could not update the job'); } } else { \Session::set_flash('error', $val->error()); } } $data['actions'] = ['view' => ['label' => 'View', 'url' => 'admin/job/view'], 'back' => ['label' => 'Back', 'url' => 'admin/job']]; $data['cities'] = \Model\City::query()->get(); $this->template->set_global('job', $job, false); $this->template->title = "Jobs"; $this->template->content = \View::forge('job/edit.twig', $data); }