Created
April 20, 2017 17:36
-
-
Save tnylea/5d0ff11438654a902767ec8f617cb50e to your computer and use it in GitHub Desktop.
Post Controller return
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function show($slug, $page = null) | |
{ | |
// GET ALL YOUR POST DATA | |
// $post = Post::where('slug', '=', $slug)->firstOrFail(); | |
// $data = ... | |
// Add this peice to the end of your show method for your post | |
if($request->ajax()){ | |
return response()->json(['url' => url('/'), 'post' => $post, 'view' => view('partials.post', $data)->render()]); | |
} else { | |
// return the original post view if it is not ajax | |
return view('post', $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment