Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use App\Http\Controllers\Admin\CategoriesController;
- use Illuminate\Http\Request;
- use App\Tag;
- use App\Post;
- use App\Category;
- use Auth;
- class HomeController extends Controller
- {
- //
- public function index()
- {
- dd($post->author);
- // dd(\App::check());
- $posts = Post::paginate(2);
- $popularPosts = Post::orderBy('views','desc')->take(3)->get();
- $featuredPosts = Post::where('is_featured',1)->take(3)->get();
- $recentPosts = Post::where('is_featured',1)->take(4)->get();
- $categories = Category::all();
- // dd($popularPosts);
- // return view('pages.index', [
- // 'posts' => $posts,
- // 'popularPosts' => $popularPosts,
- // 'featuredPosts' => $featuredPosts,
- // 'recentPosts' => $recentPosts,
- // 'categories' => $categories
- // ]);
- return view('pages.index')->with('posts', $posts);
- // return vi ew('pages.index');
- }
- public function show($slug)
- {
- $post = Post::where('slug', $slug)->firstOrFail();
- return view('pages.show', compact('post'));
- }
- public function tag($slug)
- {
- $tag = Tag::where('slug', $slug)->firstOrFail();
- // $posts = $tag->post;
- $posts = $tag->posts()->paginate(2);
- return view('pages.list', ['posts' => $posts]);
- }
- public function category($slug)
- {
- $category = Category::where('slug', $slug)->firstOrFail();
- // $posts = $category->post;
- $posts = $category->posts()->paginate(2);
- return view('pages.list', ['posts' => $posts]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment