Beispiel #1
0
 /**
  * @param $category
  * @return \Illuminate\View\View
  */
 public function category($category)
 {
     $category_id = $this->category->whereName($category)->first()->id;
     $data = $this->getOverviewData();
     $posts = $this->post->whereCategoryId($category_id)->forPublic()->orderBy('publish_date', 'DESC')->paginate($this->config->items_per_page);
     $data['posts'] = $this->dateFormat($posts);
     $data['headings'] = "All posts in <strong>" . $category . "</strong> category";
     return view('blogify.index', $data);
 }
 /**
  * Save the given category in the db
  *
  * @param CategoryRequest $request
  * @return \jorenvanhocht\Blogify\Models\Category
  */
 private function storeOrUpdateCategory($request)
 {
     $cat = $this->category->whereName($request->name)->first();
     if (count($cat) > 0) {
         $category = $cat;
     } else {
         $category = new Category();
         $category->hash = $this->blogify->makeHash('categories', 'hash', true);
     }
     $category->name = $request->name;
     $category->save();
     return $category;
 }