public function post_announce() { $validate = Announcements::validate(Input::all()); if ($validate->passes()) { $lastrow = AnnouncementComments::orderBy('created_at', 'desc')->first(); $announce = new Announcements(); $announce->employee_id = Auth::user()->employee_id; if ($lastrow == null) { $announce->post_id = mt_rand(); } else { $announce->post_id = mt_rand() . $lastrow->id; } $announce->subject = Input::get('subject'); $announce->announce = Input::get('announce'); $image = Input::file('image'); if ($image == '') { $announce->image = ''; } else { $filename = time() . '.' . $image->getClientOriginalName(); $path = public_path('img_announce/' . $filename); Image::make($image->getRealPath())->save($path); $announce->image = 'img_announce/' . $filename; } $announce->save(); return Redirect::route('announce')->with('message', 'Announcement posted successfully!'); } else { return Redirect::route('announce')->withErrors($validate)->withInput(); } }
$tpl_file = "announce.edit"; template($tpl_file); exit; } } if (isset($_POST['save']) && !empty($_POST['data']['announcement'])) { $vals = $_POST['data']['announcement']; if (isset($_POST['id'])) { $id = intval($_POST['id']); } if (!empty($_POST['data']['display_expiration'])) { $vals['display_expiration'] = Times::dateConvert($_POST['data']['display_expiration']); } if (!empty($id)) { $vals['modified'] = $time_stamp; $result = $announce->save($vals, "update", $id); } else { $vals['created'] = $vals['modified'] = $time_stamp; $result = $announce->save($vals); } if (!$result) { flash(); } } if (isset($_GET['q'])) { $conditions[] = "subject like '%" . $_GET['q'] . "%'"; } $amount = $announce->findCount(null, $conditions); $page->setPagenav($amount); $fields = "id,announcetype_id,announcetype_id as typeid,subject,message,subject AS title,message AS content,created"; setvar("ByPages", $page->pagenav);