mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.01k stars 1.43k forks source link

Laravel 5.4 Hybrid Relationships not working #1078

Closed Vasiliy-Bondarenko closed 6 years ago

Vasiliy-Bondarenko commented 7 years ago
use Jenssegers\Mongodb\Eloquent\Model;

class Post extends Model
{
    protected $connection = 'mongodb';
    protected $table = 'scheduled_posts';

    public function account()
    {
        return $this->belongsTo(Account::class, 'acc_id', 'id'); // Account model is in MySQL!!
    }
}

in Controller

        $p = Post::first();
        $a = $p->account;

Resulting error:

Call to a member function compileSelect() on null
in vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1650

screen: http://joxi.ru/L21LYKWF8VY8am

before upgrading to Laravel 5.4 was working fine...

n1ks2n commented 7 years ago

Met the same issue after updating from 5.2 to 5.4