Domanda

I'm trying to extend auth provided by Laravel and stuck at EloquentUserProvider which requires HasherInterface in constructor. How i can create this object?

È stato utile?

Soluzione

The hasher is bound to the IoC container as hash, and can be resolved from the container using a couple of different methods. The method you use usually depends on where exactly you're extending the authentication layer.

To resolve the hasher from the container:

$hasher = App::make('hash');

$hasher = $app['hash'];

When extending auth the callback you supply should receive the application container as the first parameter. You can access the hasher using the second method described above.

Auth::extend('custom', function($app)
{
    $hasher = $app['hash'];

    return YourAuthProvider($hasher);
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top