I'm working on a project which has a legacy users database. I had to write my own Hasher class (which implements "Illuminate\Contracts\Hashing\Hasher") in order to generate and check the existing hashes. This part was fairly easy and is working well.
What I'm having trouble with is getting "EloquentUserProvider" to use my Hasher implementation rather than the default "BcryptHasher".
Contextual Binding looks ideal in this case but I can't find many examples of it in use, so I'm really taking stabs in the dark.
Any ideas on how I can keep the default "BcryptHasher" for general hashing duties (eg. Hash::make()), while forcing "EloquentUserProvider" to use my Hasher class?
This is what I have so far (registered as a provider in "config/app.php"):
namespace App\Providers;
class LegacyHashServiceProvider extends \Illuminate\Hashing\HashServiceProvider
{
public function register()
{
$this->app->when('Illuminate\Auth\EloquentUserProvider')
->needs('Illuminate\Contracts\Hashing\Hasher')
->give('App\Classes\LegacyHash');
}
}
The error I'm getting is:
ReflectionException in Container.php line 741:
Class hash does not exist
1. in Container.php line 741
2. at ReflectionClass->__construct('hash') in Container.php line 741
3. at Container->build('hash', array()) in Container.php line 631
4. at Container->make('hash', array()) in Application.php line 674
5. at Application->make('hash') in Container.php line 1163
6. at Container->offsetGet('hash') in AuthManager.php line 105
7. at AuthManager->createEloquentProvider() in AuthManager.php line 91
8. at AuthManager->createEloquentDriver() in Manager.php line 87
9. at Manager->createDriver('eloquent') in AuthManager.php line 18
10. at AuthManager->createDriver('eloquent') in Manager.php line 63
...
It seems simple, but I'm puzzled. Any ideas?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1R4O1Nv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire