Friday, March 10, 2017

[SOLVED]What is the purpose of this static variable?

In the Laravel 5.4 documentation there is an example of a factory which includes a static variable $password. What is the purpose of this variable?
$factory->define(App\User::class, function (Faker\Generator $faker) {
    static $password;

    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => $password ?: $password = bcrypt('secret'),
        'remember_token' => str_random(10),
    ];
});



via Erik Berkun-Drevnig

Advertisement