File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 11<?php namespace Lio \Accounts ;
22
3+ use Carbon \Carbon ;
34use Illuminate \Auth \Reminders \RemindableTrait ;
45use Illuminate \Auth \UserInterface ;
56use Illuminate \Auth \Reminders \RemindableInterface ;
@@ -130,6 +131,17 @@ public function getLatestRepliesPaginated($max = 5)
130131 return $ this ->forumReplies ()->with ('thread ' )->paginate ($ max );
131132 }
132133
134+ public function hasCreatedAThreadRecently ()
135+ {
136+ $ thread = $ this ->forumThreads ()->first ();
137+
138+ if ($ thread ) {
139+ return $ thread ->created_at ->gte (new Carbon ('10 minutes ago ' ));
140+ }
141+
142+ return false ;
143+ }
144+
133145 /**
134146 * Get the presenter class.
135147 *
Original file line number Diff line number Diff line change @@ -73,16 +73,25 @@ public function getShowThread($threadSlug)
7373 // create a thread
7474 public function getCreateThread ()
7575 {
76+ $ this ->createSections (Input::get ('tags ' ));
77+
78+ if (Auth::user ()->hasCreatedAThreadRecently ()) {
79+ return $ this ->view ('forum.threads.throttle ' );
80+ }
81+
7682 $ tags = $ this ->tags ->getAllForForum ();
7783 $ versions = $ this ->threads ->getNew ()->getLaravelVersions ();
78- $ this ->createSections (Input::get ('tags ' ));
7984
8085 $ this ->title = "Create Forum Thread " ;
8186 $ this ->view ('forum.threads.create ' , compact ('tags ' , 'versions ' ));
8287 }
8388
8489 public function postCreateThread ()
8590 {
91+ if (Auth::user ()->hasCreatedAThreadRecently ()) {
92+ return Redirect::action ('ForumThreadsController@getCreateThread ' );
93+ }
94+
8695 return $ this ->threadCreator ->create ($ this , [
8796 'subject ' => Input::get ('subject ' ),
8897 'body ' => Input::get ('body ' ),
Original file line number Diff line number Diff line change 1+ @extends (' layouts._two_columns_left_sidebar' )
2+
3+ @section (' sidebar' )
4+ @include (' forum._sidebar' )
5+ @stop
6+
7+ @section (' content' )
8+ <div class =" header" >
9+ <h1 >Create Thread</h1 >
10+ </div >
11+
12+ <section class =" padding" >
13+ <p >Woha, slow down! You can only create a thread every 10 minutes. Please try again in a few minutes.</p >
14+ <p ><a href =" {{ action (' ForumThreadsController@getIndex' ) } }" >Back to forums.</a ></p >
15+ </section >
16+ @stop
You can’t perform that action at this time.
0 commit comments