Add (debugbar)

Update (post detail): Show detailed post
Update (post url): Improve url structure
This commit is contained in:
2023-10-04 21:15:51 +08:00
parent ffb09d090d
commit c9c6004694
6 changed files with 176 additions and 4 deletions

View File

@@ -14,7 +14,19 @@
class FrontPostController extends Controller
{
public function index(Request $request, $slug)
public function redirect(Request $request, $slug)
{
$post = Post::where('slug', $slug)->where('status', 'publish')->first();
if (is_null($post)) {
return abort(404);
}
return redirect()->route('front.post',['category_slug' => $post->category->slug, 'slug' => $post->slug]);
}
public function index(Request $request, $category_slug, $slug)
{
$post = Post::where('slug', $slug)->where('status', 'publish')->first();