| @@ 66-92 (lines=27) @@ | ||
| 63 | * |
|
| 64 | * @return \Illuminate\Http\RedirectResponse |
|
| 65 | */ |
|
| 66 | public function show(Request $request, int $id): RedirectResponse |
|
| 67 | { |
|
| 68 | $comment = Comment::findOrFail($id); |
|
| 69 | ||
| 70 | $commentsBefore = Comment::where([ |
|
| 71 | ['article_id', $comment->article_id], |
|
| 72 | ['created_at', '<', $comment->created_at] |
|
| 73 | ])->count(); |
|
| 74 | ||
| 75 | $commentsPerPage = config('xetaravel.pagination.blog.comment_per_page'); |
|
| 76 | ||
| 77 | $page = floor($commentsBefore / $commentsPerPage) + 1; |
|
| 78 | $page = ($page > 1) ? $page : 1; |
|
| 79 | ||
| 80 | $request->session()->keep(['primary', 'danger', 'warning', 'success', 'info']); |
|
| 81 | ||
| 82 | return redirect() |
|
| 83 | ->route( |
|
| 84 | 'blog.article.show', |
|
| 85 | [ |
|
| 86 | 'slug' => $comment->article->slug, |
|
| 87 | 'id' => $comment->article->id, |
|
| 88 | 'page' => $page, |
|
| 89 | '#comment-' . $comment->getKey() |
|
| 90 | ] |
|
| 91 | ); |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||
| @@ 58-84 (lines=27) @@ | ||
| 55 | * |
|
| 56 | * @return \Illuminate\Http\RedirectResponse |
|
| 57 | */ |
|
| 58 | public function show(Request $request, int $id): RedirectResponse |
|
| 59 | { |
|
| 60 | $post = DiscussPost::findOrFail($id); |
|
| 61 | ||
| 62 | $postsBefore = DiscussPost::where([ |
|
| 63 | ['conversation_id', $post->conversation_id], |
|
| 64 | ['created_at', '<', $post->created_at] |
|
| 65 | ])->count(); |
|
| 66 | ||
| 67 | $postsPerPage = config('xetaravel.pagination.discuss.post_per_page'); |
|
| 68 | ||
| 69 | $page = floor($postsBefore / $postsPerPage) + 1; |
|
| 70 | $page = ($page > 1) ? $page : 1; |
|
| 71 | ||
| 72 | $request->session()->keep(['primary', 'danger', 'warning', 'success', 'info']); |
|
| 73 | ||
| 74 | return redirect() |
|
| 75 | ->route( |
|
| 76 | 'discuss.conversation.show', |
|
| 77 | [ |
|
| 78 | 'slug' => $post->conversation->slug, |
|
| 79 | 'id' => $post->conversation->id, |
|
| 80 | 'page' => $page, |
|
| 81 | '#post-' . $post->getKey() |
|
| 82 | ] |
|
| 83 | ); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Handle a delete action for the post. |
|