@@ -22,40 +22,28 @@ public function getIndex()
2222 $ this ->view ('forum.index ' , compact ('threads ' ));
2323 }
2424
25- public function getCategory ( $ categorySlug )
25+ public function getThread ( )
2626 {
27- $ category = $ this ->categories ->requireCategoryBySlug ($ categorySlug );
28- $ threads = $ this ->comments ->getForumThreadsByCategoryPaginated ($ category );
29-
30- $ this ->view ('forum.category ' , compact ('category ' , 'threads ' ));
31- }
32-
33- public function getThread ($ categorySlug )
34- {
35- $ thread = App::make ('slugModel ' );
36- $ category = $ thread ->owner ;
27+ $ thread = App::make ('slugModel ' );
3728 $ comments = $ this ->comments ->getThreadCommentsPaginated ($ thread );
3829
39- $ this ->view ('forum.thread ' , compact ('thread ' , 'category ' , ' comments ' ));
30+ $ this ->view ('forum.thread ' , compact ('thread ' , 'comments ' ));
4031 }
4132
42- public function postThread ($ categorySlug )
33+ public function postThread ()
4334 {
4435 $ thread = App::make ('slugModel ' );
4536
46- $ category = $ this ->categories ->requireCategoryBySlug ($ categorySlug );
47-
4837 $ form = $ this ->categories ->getReplyForm ();
4938
5039 if ( ! $ form ->isValid ()) {
5140 return $ this ->redirectBack (['errors ' => $ form ->getErrors ()]);
5241 }
5342
5443 $ comment = $ this ->comments ->getNew ([
55- 'body ' => Input::get ('body ' ),
56- 'author_id ' => Auth::user ()->id ,
57- 'parent_id ' => $ thread ->id ,
58- 'type ' => Comment::TYPE_FORUM ,
44+ 'body ' => Input::get ('body ' ),
45+ 'author_id ' => Auth::user ()->id ,
46+ 'type ' => Comment::TYPE_FORUM ,
5947 ]);
6048
6149 if ( ! $ comment ->isValid ()) {
@@ -64,18 +52,16 @@ public function postThread($categorySlug)
6452
6553 $ thread ->children ()->save ($ comment );
6654
67- return $ this ->redirectAction ('Controllers\ForumController@getThread ' , [$ categorySlug , $ thread ->slug ->slug ]);
55+ return $ this ->redirectAction ('Controllers\ForumController@getThread ' , [$ thread ->slug ->slug ]);
6856 }
6957
7058 public function getCreateThread ()
7159 {
7260 $ this ->view ('forum.createthread ' );
7361 }
7462
75- public function postCreateThread ($ categorySlug )
63+ public function postCreateThread ()
7664 {
77- $ category = $ this ->categories ->requireCategoryBySlug ($ categorySlug );
78-
7965 $ form = $ this ->categories ->getThreadForm ();
8066
8167 if ( ! $ form ->isValid ()) {
@@ -86,18 +72,17 @@ public function postCreateThread($categorySlug)
8672 'title ' => Input::get ('title ' ),
8773 'body ' => Input::get ('body ' ),
8874 'author_id ' => Auth::user ()->id ,
89- 'category_slug ' => $ category ->slug ,
9075 'type ' => Comment::TYPE_FORUM ,
9176 ]);
9277
9378 if ( ! $ comment ->isValid ()) {
9479 return $ this ->redirectBack (['errors ' => $ comment ->getErrors ()]);
9580 }
9681
97- $ category -> rootThreads () ->save ($ comment );
82+ $ this -> comments ->save ($ comment );
9883
9984 $ commentSlug = $ comment ->slug ()->first ()->slug ;
10085
101- return $ this ->redirectAction ('Controllers\ForumController@getThread ' , [$ categorySlug , $ commentSlug ]);
86+ return $ this ->redirectAction ('Controllers\ForumController@getThread ' , [$ commentSlug ]);
10287 }
10388}
0 commit comments