示例#1
0
 public function showCategory($slug)
 {
     $categories = Category::all();
     $category = Category::whereSlug($slug)->first();
     $posts = Post::isPublished()->where('category_id', $category->id)->paginate(10);
     return view('blog::category.show')->withPageTitle($category->name)->withPosts($posts)->withCategory($category)->withCategories($categories)->withActiveCategory($category->id);
 }
示例#2
0
 public function ajax_post_publish()
 {
     $post_id = Input::get('post_id');
     $post = Post::find($post_id);
     if ($post->published_at === '0000-00-00 00:00:00') {
         $post->published_at = DB::raw('now()');
         $post->save();
     }
     return response()->json($post);
 }