public function update($id)
{
$input = Input::all();
if (isset($input['form_close'])) {
return Redirect::to("backend/{$input['type']}s");
}
$categories = Input::get('categories', array());
try {
$post = Post::findOrFail($id);
$post->update($input);
$post->categories()->sync($categories);
$redirect = isset($input['form_save']) ? "backend/{$input['type']}s" : "backend/{$input['type']}s/create";
return Redirect::to($redirect)->with('success_message', 'The ' . $this->type . ' was updated.');
} catch (ValidationException $e) {
return Redirect::back()->withInput()->withErrors($e->getErrors());
}
}