Add Throttle Rate Limit

This commit is contained in:
SahrulGnwn 2022-08-11 18:45:27 +07:00
parent fe4779d6bf
commit c1f765af01
3 changed files with 9 additions and 3 deletions

View file

@ -91,7 +91,7 @@ class TicketsController extends Controller
return $tickets->ticketcategory->name;
})
->editColumn('title', function (Ticket $tickets) {
return '<a class="text-info" target="_blank" href="' . route('moderator.ticket.show', ['ticket_id' => $tickets->ticket_id]) . '">' . "#" . $tickets->ticket_id . " - " . $tickets->title . '</a>';
return '<a class="text-info" href="' . route('ticket.show', ['ticket_id' => $tickets->ticket_id]) . '">' . "#" . $tickets->ticket_id . " - " . $tickets->title . '</a>';
})
->editColumn('status', function (Ticket $tickets) {
switch ($tickets->status) {

View file

@ -59,5 +59,11 @@ class RouteServiceProvider extends ServiceProvider
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
RateLimiter::for('ticket-new', function (Request $request) {
return Limit::perMinute(3)->by(optional($request->user())->id ?: $request->ip());
});
RateLimiter::for('ticket-reply', function (Request $request) {
return Limit::perMinute(4)->by(optional($request->user())->id ?: $request->ip());
});
}
}

View file

@ -98,9 +98,9 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
Route::get('ticket', [TicketsController::class, 'index'])->name('ticket.index');
Route::get('ticket/datatable', [TicketsController::class, 'datatable'])->name('ticket.datatable');
Route::get('ticket/new', [TicketsController::class, 'create'])->name('ticket.new');
Route::post('ticket/new', [TicketsController::class, 'store'])->name('ticket.new.store');
Route::post('ticket/new', [TicketsController::class, 'store'])->middleware(['throttle:ticket-new'])->name('ticket.new.store');
Route::get('ticket/show/{ticket_id}', [TicketsController::class, 'show'])->name('ticket.show');
Route::post('ticket/reply', [TicketsController::class, 'reply'])->name('ticket.reply');
Route::post('ticket/reply', [TicketsController::class, 'reply'])->middleware(['throttle:ticket-reply'])->name('ticket.reply');
}
#admin