/** * Update the specified emailtemplate in storage. * * @param int $id * @return Response */ public function update($id) { $emailtemplate = EmailTemplate::findOrFail($id); $validator = Validator::make($data = Input::all(), EmailTemplate::rules($id)); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $emailtemplate->update($data); return Redirect::route('admin.templates.index')->with("message", "Data berhasil disimpan"); }
public function post_emailtemplateedit($id) { //Verify we are editing our own template (unless we our access level is > 0) if (Auth::consoleuser()->get()->access < 1) { $check = EmailTemplate::where('id', '=', $id)->where('author', '=', Auth::consoleuser()->get()->cid)->count(); if ($check < 1) { return Redirect::route('consoleemailtemplates')->with('error', 'Unauthorized template edit'); } } //Pull our fields $name = Input::get('inputName'); $subject = Input::get('inputSubject'); $content = Input::get('inputContent'); $public = Input::get('inputPublic'); if (empty($name) || empty($subject) || empty($content)) { return Redirect::to('console/emailtemplates/edit/' . $id)->with('error', 'Please complete all of the required fields.'); } if ($public != 1) { $public = 0; } //All clear let's update the db $template = EmailTemplate::findOrFail($id); $template->name = $name; $template->subject = $subject; $template->content = $content; $template->public = $public; $template->save(); return Redirect::route('consoleemailtemplates')->with('message', 'Template Updated.'); }
public function postEditEmailTemplate() { if (!Input::has('id')) { return Redirect::route(self::EmailHome); } $input = Input::all(); try { $tpl = EmailTemplate::findOrFail($input['id']); $tpl->fill($input); $this->flash($tpl->save()); return Redirect::route(self::EmailHome); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { App::abort(404); } }