File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Potelo \LaravelBlockBots \Events ;
4+
5+ use Carbon \Carbon ;
6+ use Illuminate \Queue \SerializesModels ;
7+
8+ class BotBlockedEvent
9+ {
10+ use SerializesModels;
11+
12+ public $ ip ;
13+
14+ /** @var integer */
15+ public $ number_of_hits ;
16+
17+ /** @var Carbon */
18+ public $ block_date ;
19+
20+ /**
21+ * Create a new event instance.
22+ *
23+ * @param $ip
24+ * @param integer $number_of_hits
25+ * @param Carbon $block_date
26+ *
27+ * @return void
28+ */
29+ public function __construct ($ ip , $ number_of_hits , $ block_date )
30+ {
31+ $ this ->ip = $ ip ;
32+ $ this ->number_of_hits = $ number_of_hits ;
33+ $ this ->block_date = $ block_date ;
34+ }
35+ }
Original file line number Diff line number Diff line change 1010use Potelo \LaravelBlockBots \Events \UserBlockedEvent ;
1111use Potelo \LaravelBlockBots \Jobs \ProcessLogWithIpInfo ;
1212use Potelo \LaravelBlockBots \Abstracts \AbstractBlockBots ;
13-
13+ use Potelo \ LaravelBlockBots \ Events \ BotBlockedEvent ;
1414
1515class BlockBots extends AbstractBlockBots
1616{
@@ -55,6 +55,9 @@ protected function notAllowed()
5555 event (new UserBlockedEvent (Auth::user (), $ this ->hits , Carbon::now ()));
5656 }
5757
58+ if (Auth::guest () && $ this ->isTheFirstOverflow ()) {
59+ event (new BotBlockedEvent ($ this ->client ->ip , $ this ->hits , Carbon::now ()));
60+ }
5861
5962 if ($ this ->request ->expectsJson ()) {
6063 return response ()->json ($ this ->options ->json_response , 429 );
You can’t perform that action at this time.
0 commit comments