/** * @param string $hash * @return \Illuminate\Http\RedirectResponse */ public function destroy($hash) { $category = $this->category->byHash($hash); $category_name = $category->name; $category->delete(); $this->tracert->log('categories', $category->id, $this->auth_user->id, 'delete'); $message = trans('blogify::notify.success', ['model' => 'Categorie', 'name' => $category_name, 'action' => 'deleted']); session()->flash('notify', ['success', $message]); return redirect()->route('admin.categories.index'); }
/** * Build a post object when there * is a cached post so we can put * the data back in the form * * @return object */ private function buildPostObject() { $hash = $this->auth_user->hash; $cached_post = $this->cache->get("autoSavedPost-{$hash}"); $post = []; $post['hash'] = ''; $post['title'] = $cached_post['title']; $post['slug'] = $cached_post['slug']; $post['content'] = $cached_post['content']; $post['publish_date'] = $cached_post['publishdate']; $post['status_id'] = $this->status->byHash($cached_post['status'])->id; $post['visibility_id'] = $this->visibility->byHash($cached_post['visibility'])->id; $post['reviewer_id'] = $this->user->byHash($cached_post['reviewer'])->id; $post['category_id'] = $this->category->byHash($cached_post['category'])->id; $post['tag'] = $this->buildTagsArrayForPostObject($cached_post['tags']); return objectify($post); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $segment = $this->segment(3); $id = isset($segment) ? $this->category->byHash($this->segment(3))->id : 0; return ['name' => "required|unique:categories,name,{$id}|min:3|max:45"]; }