Laravel-mongodb: Call to a member function prepare() on null

Created on 23 May 2018  Â·  16Comments  Â·  Source: jenssegers/laravel-mongodb

I cant generate php artisan passport:install, I had try to change

`

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
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',
];

}'

into
`

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class User extends Eloquent implements Authenticatable
{
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',
];

}`

but , it didnt work properly.
need help pls

Most helpful comment

I'm not sure about your error maybe you can show the error log to see whats wrong with it but as I can see you are using auth interface so ;
Use this use Jenssegers\Mongodb\Auth\User as Authenticatable instead of use Illuminate\Foundation\Auth\User as Authenticatable

All 16 comments

I'm not sure about your error maybe you can show the error log to see whats wrong with it but as I can see you are using auth interface so ;
Use this use Jenssegers\Mongodb\Auth\User as Authenticatable instead of use Illuminate\Foundation\Auth\User as Authenticatable

I guess it's linked to MorphMany missing functionality.

_edit:_ Found this https://stackoverflow.com/a/42107515

Works for me @kwame101 , thanks!

I got the same error while working with laravel cashier braintree and mongodb as database.

I solved it by editing in vendor

  • go in vendor/laravel/cashier-braintree/src/subcription.php
  • change "use Illuminate\Database\Eloquent\Model" line with "use Jenssegers\Mongodb\Eloquent\Model"
    -Done

if you make your own ORM, make sure you replace the base model like so

<?php
namespace App\Models;

use Jenssegers\Mongodb\Eloquent\Model;

class Product extends Model
{
    protected $collection = 'products';
}

Laravel Version: 5.7
PHP Version:7.1
Laravel-admin: latest

After first installing
https://github.com/jenssegers/laravel-mongodb

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function prepare() on null

Symfony\Component\Debug\Exception\FatalThrowableError
…/vendor/laravel/framework/src/Illuminate/Database/Connection.php326

vendor/laravel/framework/src/Illuminate/Database/Connection.php

any solution?

@devenpateldp This should fix your issue.

TRY THIS : https://github.com/sadnub/laravel-mongodb-passport-fix WORKED FOR ME

@Jchegenye Thank you so much in advance let me try again.

@Jchegenye tried same again still issue same. if anything else please let me know.

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function prepare() on null

Application frames (1) All frames (2)
1
Symfony
\Component
\Debug
\Exception
\FatalThrowableError
…
/vendor
/laravel
/framework
/src
/Illuminate
/Database
/Connection.php
326
0
{main}
…
/public
/index.php
0

use my package for mongodb(based to Laravel passport, so you can use Passport doc)
https://packagist.org/packages/sedrak/laravel-mongodb-passport
remove larvel passport from composer and install this.

@sedrak1987 thank you will check and report.

@Racsodia thank you let me review.

I have also the same problem.
To fix it, i changed in all Passport file
"use Illuminate\Database\Eloquent\Model" by
"use Jenssegers\Mongodb\Eloquent\Model"

list of the files where i changed : /vendor/laravel/passport/src/AuthCode.php
/vendor/laravel/passport/src/Client.php
/vendor/laravel/passport/src/PersonalAccessClient.php
/vendor/laravel/passport/src/RefreshToken.php
/vendor/laravel/passport/src/Token.php
In my case, i wanted to use Passport with mongodb like database.

I have also the same problem, thank you to @AbouOpenSource he gave me the idea of search "use Illuminate\Database\Eloquent\Model" and changed in this file: /vendor/laravel/framework/src/Illuminate/Notifications/DatabaseNotification.

My problem was with notify method.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yupangestu picture yupangestu  Â·  3Comments

geofflancaster picture geofflancaster  Â·  3Comments

BlakeGardner picture BlakeGardner  Â·  3Comments

bastiendonjon picture bastiendonjon  Â·  3Comments

viacheslavpleshkov picture viacheslavpleshkov  Â·  3Comments