Laravel-mongodb: Auth on laravel 5.7 not working normally

Created on 10 Oct 2018  路  7Comments  路  Source: jenssegers/laravel-mongodb

This is the user model

<?php


namespace SomeApp;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
// use Illuminate\Foundation\Auth\User as Authenticatable;
use Jenssegers\Mongodb\Auth\User as Authenticatable;


class User extends Authenticatable //implements MustVerifyEmail
{
    use Notifiable;
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

This is the error

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Argument 1 passed to Jenssegers\Mongodb\Query\Builder::__construct() must be an instance of Jenssegers\Mongodb\Connection, instance of Illuminate\Database\MySqlConnection given, called in `\vendor\jenssegers\mongodb\src\Jenssegers\Mongodb\Eloquent\Model.`

if i implements must verify email

class User extends Authenticatable implements MustVerifyEmail

it will cause the following error

Class SomeApp\User contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Contracts\Auth\MustVerifyEmail::hasVerifiedEmail, Illuminate\Contracts\Auth\MustVerifyEmail::markEmailAsVerified, Illuminate\Contracts\Auth\MustVerifyEmail::sendEmailVerificationNotification)

All 7 comments

can you implement the 3 missing methods that are mentioned in the exception you got?

As the User.php implemente the MustVerifyEmail Interface it should implement all the declared methodes in it .
We have 3 methods in Illuminate\Contracts\Auth\MustVerifyEmail.php and therfor you should implement them in your User.php model.

Now for the content of thouse 3 methodes I don't know if we should implement our own code or not !?

   /**
     * Determine if the user has verified their email address.
     *
     * @return bool
     */
    public function hasVerifiedEmail(){}

    /**
     * Mark the given user's email as verified.
     *
     * @return bool
     */
    public function markEmailAsVerified(){}

    /**
     * Send the email verification notification.
     *
     * @return void
     */
    public function sendEmailVerificationNotification(){}

yeah, of course you need to add your own business logic here..

i fail to make it even without implement MustVerifyEmail
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR) Argument 1 passed to Jenssegers\Mongodb\Query\Builder::__construct() must be an instance of Jenssegers\Mongodb\Connection, instance of Illuminate\Database\MySqlConnection given

thus i was like not sure if i need to change the db connection to my mongoDB some where ?

of course you need to create a mongodb connection..

@drmmyx Did you manage to get this working? I am having the same trouble here: https://github.com/jenssegers/laravel-mongodb/issues/1678

Below Its Work For me
Please use this in User.php

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\MustVerifyEmail as MustVerifyEmailContract;

class User extends Authenticatable implements MustVerifyEmail
{
use MustVerifyEmail, Notifiable;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

naveedyasin picture naveedyasin  路  3Comments

tomartailored picture tomartailored  路  3Comments

geofflancaster picture geofflancaster  路  3Comments

viacheslavpleshkov picture viacheslavpleshkov  路  3Comments

yupangestu picture yupangestu  路  3Comments