Laravel类型错误:传递的参数1必须是给定的数组字符串

时间:2017-07-21 08:22:01

标签: php laravel

我试图收到一封电子邮件来重置管理员密码,并在处理令牌时收到此错误。

(1/1) FatalThrowableError
Type error: Argument 1 passed to Illuminate\Auth\Passwords\PasswordBrokerManager::createTokenRepository() must be of the type array, string given, called in /home/vagrant/Code/Manifiesto2017/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php on line 71

这些是:

protected function resolve($name)
{
    $config = $this->getConfig($name);

    if (is_null($config)) {
        throw new InvalidArgumentException("Password resetter [{$name}] is not defined.");
    }

    // The password broker uses a token repository to validate tokens and send user
    // password e-mails, as well as validating that password reset process as an
    // aggregate service of sorts providing a convenient interface for resets.
    return new PasswordBroker(
        $this->createTokenRepository($config),   <!--THIS!!!!
        $this->app['auth']->createUserProvider($config['provider'])
    );
}

createtokenrepository函数是这样的:

protected function createTokenRepository(array $config)
{
    $key = $this->app['config']['app.key'];

    if (Str::startsWith($key, 'base64:')) {
        $key = base64_decode(substr($key, 7));
    }

    $connection = isset($config['connection']) ? $config['connection'] : null;

    return new DatabaseTokenRepository(
        $this->app['db']->connection($connection),
        $this->app['hash'],
        $config['table'],
        $key,
        $config['expire']
    );
}

我无法查看错误的位置,我们将不胜感激任何帮助。

解决

问题在于$ config = $ this-&gt; getConfig($ name)只需要&#39; admins&#39;并没有拿走桌子,到期时间..

文件auth.php错误,在底部看起来像这样:

'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
        'admins' => 'admins',
        'table' => 'password_resets',
        'expire' => 15,
    ],

应该是这样的:

  'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
        'admins' => [
            'provider' => 'admins',
            'table' => 'password_resets',
            'expire' => 15,
        ],
    ],

0 个答案:

没有答案