php – Sintaxe ‘:value’ no array

Question:

I've seen this syntax in laravel, in the 'resources/lang' area, where authentication messages are pre-configured. And I came across the following code:

<?php

return [

   'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',

];

Where it says ':seconds', I would like to know, where does this value come from and how to display it correctly.

Answer:

Inside app\Http\Controllers\Auth\LoginController.php Add this override method

 /**
 * Determina a quantidade de tentativas de acesso caso a senha esteja errada
 * 6 Tentativas por 30 minutos
 * @param  \Illuminate\Http\Request  $request
 * @return bool
 */
protected function hasTooManyLoginAttempts(Request $request)
{
    return $this->limiter()->tooManyAttempts(
        $this->throttleKey($request), 6, 30 
    );
}

This value comes from Laravel's CORE, this method above is to override the default code. If you are using AUTH correctly within Laravel, this message will be displayed automatically, and the value to be displayed will be according to what you have edited. This structure is for you to be able to add translation packages within your project.

Here's a repository to help translate your project.

https://github.com/caouecs/Laravel-lang

Scroll to Top