Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\Http\Requests;
- use App\User;
- use App\Post;
- use App\Category;
- use Mail;
- use Session;
- class PostsController extends Controller {
- public function getIndex() {
- $posts = Post::orderBy('created_at', 'desc')->paginate(5);
- return view('front.posts.index')->withPosts($posts);
- }
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id, $slug = '')
- {
- $post = Post::findOrFail($id);
- if ($slug !== $post->slug) {
- return redirect()->to($post->slug, 301);
- }
- return view('front.posts.show')->withPost($post);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement