Skip to content

Commit 1968454

Browse files
author
Shawn McCool
committed
rename foum views
move comment type to forum creator class
1 parent bfafc48 commit 1968454

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

app/Lio/Forum/ForumThreadCreator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function create(ForumThreadCreatorObserver $observer, $data, $validator =
3131

3232
private function createValidRecord($observer, $data)
3333
{
34-
$thread = $this->comments->getNew($data);
34+
$thread = $this->comments->getNew($data + [
35+
'type' => Comment::TYPE_FORUM,
36+
]);
3537

3638
// check the model validation
3739
if ( ! $this->comments->save($thread)) {

app/controllers/ForumController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getShowThread()
5252
{
5353
$thread = App::make('slugModel');
5454
$comments = $this->comments->getThreadCommentsPaginated($thread, $this->commentsPerPage);
55-
$this->view('forum.thread', compact('thread', 'comments'));
55+
$this->view('forum.showthread', compact('thread', 'comments'));
5656
}
5757

5858
// create a thread
@@ -70,7 +70,6 @@ public function postCreateThread()
7070
'title' => Input::get('title'),
7171
'body' => Input::get('body'),
7272
'author_id' => Auth::user()->id,
73-
'type' => Comment::TYPE_FORUM,
7473
'laravel_version' => Input::get('laravel_version'),
7574
'tags' => $tags,
7675
], new ForumThreadForm);
@@ -122,6 +121,7 @@ public function forumThreadUpdated($thread)
122121
// bounces the user to the correct page of a thread for the indicated comment
123122
public function getCommentRedirect($thread, $commentId)
124123
{
124+
// refactor this
125125
$comment = Comment::findOrFail($commentId);
126126
$numberCommentsBefore = Comment::where('parent_id', '=', $comment->parent_id)->where('created_at', '<', $comment->created_at)->count();
127127
$page = round($numberCommentsBefore / $this->commentsPerPage, 0, PHP_ROUND_HALF_DOWN) + 1;
@@ -167,13 +167,15 @@ public function getSearch()
167167
{
168168
$query = Input::get('query');
169169
$results = App::make('Lio\Comments\ForumSearch')->searchPaginated($query, $this->threadsPerPage);
170+
170171
$this->view('forum.search', compact('query', 'results'));
171172
}
172173

173174
// reply to a thread
174175
public function postCreateReply()
175176
{
176177
$thread = App::make('slugModel');
178+
177179
return App::make('Lio\Forum\ForumReplyCreator')->create($this, [
178180
'body' => Input::get('body'),
179181
'author_id' => Auth::user()->id,
@@ -185,7 +187,8 @@ public function getEditReply($replyId)
185187
{
186188
$reply = $this->comments->requireForumThreadById($replyId);
187189
if (Auth::user()->id != $reply->author_id) return Redirect::to('/');
188-
$this->view('forum.editcomment', compact('reply'));
190+
191+
$this->view('forum.editreply', compact('reply'));
189192
}
190193

191194
public function postEditReply($replyId)

app/views/forum/editcomment.blade.php renamed to app/views/forum/editreply.blade.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
@stop
66

77
@section('content')
8-
<div class="header">
9-
<h1>Edit Your Reply</h1>
10-
</div>
8+
<div class="header">
9+
<h1>Edit Your Reply</h1>
10+
</div>
1111

1212
<div class="reply-form">
1313
{{ Form::model($reply->resource) }}
@@ -21,6 +21,7 @@
2121
<div class="form-row">
2222
{{ Form::button('Reply', ['type' => 'submit', 'class' => 'button']) }}
2323
</div>
24+
{{ Form::close() }}
2425
</div>
2526
@stop
2627

0 commit comments

Comments
 (0)