Syntax ':value' in the array

Asked

Viewed 60 times

3

I saw this syntax in the 'Resources/lang' area, where authentication messages are preset. And I came across the following code:

<?php

return [

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

];

Where is written ':Seconds', I would like to know, where this value comes from and how to display it correctly.

1 answer

0


Within Http Controllers Auth Logincontroller.php app 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 serves to override the default code. If you are using the AUTH correctly inside Laravel, this message will be automatically displayed, and the value to be shown will be according to what you edited. This structure is for you to be able to add translation packages within your project.

Here’s a repository to help you translate your project.

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

  • I could do or use this kind of system in a project from scratch?

  • Do you say auth? or are you talking about the repository?

  • I talk like this, a project without Laravel, if I want to do this for example: <?php Return [ 'Welcome' => 'Welcome :user' ] ? > Ouput: Welcome, So-and-so

  • 1

    Yes, a simpler example is that of the site php.net : http://php.net/manual/en/features.http-auth.php. , I believe that something simpler, or drier than this other example , does not compensate, because we are talking about security, and these solutions have been tested and developed for a long time by a large community.

  • Really, thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.