public function catposts($category) { if (is_numeric($category)) { $cat = Category::find($category)->id; } else { $column = 'category'; // This is the name of the column you wish to search $cat = Category::where($column, '=', $category)->first()->id; } $catname = Category::find($cat); $posts = Post::where('category', $cat)->orderBy('id', 'desc')->paginate(5); //var_dump($posts); return view('catposts')->with('posts', $posts)->with('catname', $catname); }
public function tags($tag) { $posts = Post::where('tags', 'LIKE', '%' . $tag . '%')->get(); return view('tags')->with('posts', $posts)->with('tag', $tag); }