Level 2
Jul 9, 2019
1
Level 2
Is extending a model to multiple classes possible?
To use Mongodb my model needs to have:
...
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent
...
my User Model looks like this:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class User extends Authenticatable
{
use Notifiable, HasApiTokens;
/**
* 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',
];
public function property() {
return $this->hasMany('App\Property', 'userid');
}
}
when I change Authenticatable to Eloquent I get this error:
Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given, called in /home/ubuntu/xxx/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 377
when I leave it as Authenticatable, I get this error:
"Call to a member function prepare() on null"
which is normally what happens when I don't include it..
Any ideas how I can make this work?
Please or to participate in this conversation.