Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

416
Views
:seconds to :hours in Laravel Throttle?

In my

resources/lang/en/auth.php

I have this

<?php

return [

/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| message that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/

'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',

];

Is there a way to edit the throttle :seconds to an hour?

the error message on the front would be something like this

Too many login attempts. Please try again in 2 hour(s).

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

By default, the throttle login trait only give minutes and seconds, if you want to add hours just override sendLockoutResponse method from Illuminate\Foundation\Auth\ThrottlesLogins like below(in LoginController that use AuthenticatesUsers trait ):

/**
 * Redirect the user after determining they are locked out.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return void
 *
 * @throws \Illuminate\Validation\ValidationException
 */
protected function sendLockoutResponse(Request $request)
{
    $seconds = $this->limiter()->availableIn(
        $this->throttleKey($request)
    );

    throw ValidationException::withMessages([
        $this->username() => [trans('auth.throttle', [
            'seconds' => $seconds,
            'minutes' => ceil($seconds / 60),
            'hours' => ceil($seconds / 60 / 60),
        ])],
    ])->status(Response::HTTP_TOO_MANY_REQUESTS);
}

Now you can add hours throttles like below:

'throttle' => 'Too many login attempts. Please try again in :hours hour(s).',
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!