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 1
1
<?php namespace Lio \Accounts ;
2
2
3
+ use Carbon \Carbon ;
3
4
use Illuminate \Auth \Reminders \RemindableTrait ;
4
5
use Illuminate \Auth \UserInterface ;
5
6
use Illuminate \Auth \Reminders \RemindableInterface ;
@@ -130,6 +131,17 @@ public function getLatestRepliesPaginated($max = 5)
130
131
return $ this ->forumReplies ()->with ('thread ' )->paginate ($ max );
131
132
}
132
133
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
+
133
145
/**
134
146
* Get the presenter class.
135
147
*
Original file line number Diff line number Diff line change @@ -73,16 +73,25 @@ public function getShowThread($threadSlug)
73
73
// create a thread
74
74
public function getCreateThread ()
75
75
{
76
+ $ this ->createSections (Input::get ('tags ' ));
77
+
78
+ if (Auth::user ()->hasCreatedAThreadRecently ()) {
79
+ return $ this ->view ('forum.threads.throttle ' );
80
+ }
81
+
76
82
$ tags = $ this ->tags ->getAllForForum ();
77
83
$ versions = $ this ->threads ->getNew ()->getLaravelVersions ();
78
- $ this ->createSections (Input::get ('tags ' ));
79
84
80
85
$ this ->title = "Create Forum Thread " ;
81
86
$ this ->view ('forum.threads.create ' , compact ('tags ' , 'versions ' ));
82
87
}
83
88
84
89
public function postCreateThread ()
85
90
{
91
+ if (Auth::user ()->hasCreatedAThreadRecently ()) {
92
+ return Redirect::action ('ForumThreadsController@getCreateThread ' );
93
+ }
94
+
86
95
return $ this ->threadCreator ->create ($ this , [
87
96
'subject ' => Input::get ('subject ' ),
88
97
'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