public function view_tintuc($id, $title) { if (Cache::has('view_tintuc' . $id)) { $data['tintuc'] = Cache::get('view_tintuc' . $id); } else { $data['tintuc'] = Cache::remember('view_tintuc' . $id, 15, function () use($id) { return Tintuc::find($id); }); } $data['title'] = $title; return View::make('template.view_tintuc', $data); }
public function post_edit_tintuc() { $data = Input::all(); $valid = Validator::make($data, Tintuc::$edit_tintuc_rules, Tintuc::$add_tintuc_language); if ($valid->passes()) { $tintuc = Tintuc::find(Input::get('id')); $tintuc->title = Input::get('title'); $tintuc->mota = Input::get('mota'); $tintuc->noidung = Input::get('noidung'); $tintuc->save(); return Redirect::to(Input::get('url'))->with('tintuc_success', 'Sửa tin thành công'); } else { return Redirect::to(Input::get('url'))->with('tintuc_error', $valid->errors()->first()); } }