laravel-mongodb
laravel-mongodb copied to clipboard
[Laravel 5.4] User model doesn't work
App/User.php
namespace App;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Eloquent implements Authenticatable
{
use Notifiable;
protected $collection = 'users';
}
config/app.php
Jenssegers\Mongodb\MongodbServiceProvider::class,
Error:
FatalErrorException in User.php line 9:
App\User cannot implement Illuminate\Foundation\Auth\User - it is not an interface
Hi drewlag,
Try the following :
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
class User extends Eloquent implements AuthenticatableContract,
Replace
use Illuminate\Foundation\Auth\User as Authenticatable;
with
use Jenssegers\Mongodb\Auth\User as Authenticatable;
It should look like this then
namespace App;
use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $collection = 'users';
}
I do not think you can implement a class, only interfaces.
If this worked, please close this issue.
use Jenssegers\Mongodb\Auth\User as Authenticatable;
This worked for me. Thank you @microwavekonijn
I would suggest adding this to the documentation in README.md.
Thank you @microwavekonijn. This worked for me (using Laravel 5.5). I lost way too much time finding this. How could it not be in the docs?!
This thread also helped me immensely. Cheers @microwavekonijn
This is not working on laravel 6.2
This is not working on laravel 6.2
Not working for me as well on Laravel 6
Same issue with Laravel 8
@nifunifatralara are you find any solution for laravel8? I also got trouble :(
@nifunifatralara are you find any solution for laravel8? I also got trouble :(
The answer has been given here multiple times.
Thanks!