Skip to content

Commit e5f583a

Browse files
author
Shawn McCool
committed
begin refactoring away old forum category paradigm
1 parent c1ba0cb commit e5f583a

12 files changed

+50
-165
lines changed

app/Controllers/ForumController.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ public function __construct(ForumCategoryRepository $categories, CommentReposito
1818

1919
public function getIndex()
2020
{
21-
$categories = $this->categories->getForumIndex();
22-
23-
$this->view('forum.index', compact('categories'));
21+
$threads = $this->comments->getForumThreadsByTagsPaginated();
22+
$this->view('forum.index', compact('threads'));
2423
}
2524

2625
public function getCategory($categorySlug)
@@ -68,11 +67,9 @@ public function postThread($categorySlug)
6867
return $this->redirectAction('Controllers\ForumController@getThread', [$categorySlug, $thread->slug->slug]);
6968
}
7069

71-
public function getCreateThread($categorySlug)
70+
public function getCreateThread()
7271
{
73-
$category = $this->categories->requireCategoryBySlug($categorySlug);
74-
75-
$this->view('forum.createthread', compact('category'));
72+
$this->view('forum.createthread');
7673
}
7774

7875
public function postCreateThread($categorySlug)

app/database/migrations/2013_09_19_101513_create_forum_categories_table.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

app/database/migrations/2013_09_19_105004_add_forum_category_slug_field.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/database/migrations/2013_09_19_155942_add_most_recent_post_field_to_forum_categories.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/database/migrations/2013_09_20_123916_add_category_slug_field_to_comments.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/domain/Lio/Comments/CommentRepository.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ public function __construct(Comment $model)
1010
$this->model = $model;
1111
}
1212

13-
public function getForumThreadsByCategoryPaginated(ForumCategory $category, $perPage = 20)
13+
public function getForumThreadsByTagsPaginated($tags = [], $perPage = 20)
1414
{
1515

16-
return $this->model->with(['slug', 'mostRecentChild'])
17-
->where('owner_type', '=', 'Lio\Forum\ForumCategory')
18-
->where('owner_id', '=', $category->id)
19-
->paginate($perPage);
16+
return $this->model->with(['slug', 'mostRecentChild'])->paginate($perPage);
2017
}
2118

2219
public function getThreadCommentsPaginated(Comment $thread, $perPage = 20)

app/routes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
// forum
3838
Route::get('forum', 'Controllers\ForumController@getIndex');
3939
Route::get('forum/{forumCategory}', 'Controllers\ForumController@getCategory');
40-
Route::get('forum/{forumCategory}/create-thread', ['before' => 'auth', 'uses' => 'Controllers\ForumController@getCreateThread']);
41-
Route::post('forum/{forumCategory}/create-thread', ['before' => 'auth', 'uses' => 'Controllers\ForumController@postCreateThread']);
40+
Route::get('forum/create-thread', ['before' => 'auth', 'uses' => 'Controllers\ForumController@getCreateThread']);
41+
Route::post('forum/create-thread', ['before' => 'auth', 'uses' => 'Controllers\ForumController@postCreateThread']);
4242
Route::get('forum/{forumCategory}/{slug}', ['before' => 'handle_slug', 'uses' => 'Controllers\ForumController@getThread']);
4343
Route::post('forum/{forumCategory}/{slug}', ['before' => 'auth|handle_slug', 'uses' => 'Controllers\ForumController@postThread']);
4444

app/storage/dumps/.gitignore

100644100755
File mode changed.

app/views/articles/_sidebar.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}">All Articles</a></li>
55
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=installation,configuration">Installation / Configuration</a></li>
66
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=authentication,security">Authentication / Security</a></li>
7-
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=requests,input">Requests / Input</a></li>
7+
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=requests,input">Requests / Input / Responses</a></li>
88
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=session,cache">Session / Cache</a></li>
99
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=database,eloquent">Database / Eloquent</a></li>
1010
<li><a href="{{ action('Controllers\ArticlesController@getIndex') }}?tags=architecture,ioc">Architecture / IoC</a></li>

app/views/forum/_sidebar.blade.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="categories">
2+
<h4>Categories</h4>
3+
<ul>
4+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}">All Threads</a></li>
5+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=installation,configuration">Installation / Configuration</a></li>
6+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=authentication,security">Authentication / Security</a></li>
7+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=requests,input">Requests / Input / Responses</a></li>
8+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=session,cache">Session / Cache</a></li>
9+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=database,eloquent">Database / Eloquent</a></li>
10+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=architecture,ioc">Architecture / IoC</a></li>
11+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=views,blade,forms">Views / Blade / Forms</a></li>
12+
<li><a href="{{ action('Controllers\ForumController@getIndex') }}?tags=mail,queues">Mail / Queues</a></li>
13+
</ul>
14+
</div>
15+
16+
<div id="new">
17+
<h4>Create an Thread</h4>
18+
<p>Forum threads are a way to begin a discussion over a specific topic. Is there a topic that you'd like to discuss that you don't see in the forum?</p>
19+
<a class="button full" href="{{ action('Controllers\ForumController@getCreateThread') }}">Create a Thread</a>
20+
</div>

0 commit comments

Comments
 (0)