Skip to content

mongo parent using has() with mysql children and hybridrelations #1159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vesper8 opened this issue Mar 21, 2017 · 1 comment
Closed

mongo parent using has() with mysql children and hybridrelations #1159

vesper8 opened this issue Mar 21, 2017 · 1 comment

Comments

@vesper8
Copy link

vesper8 commented Mar 21, 2017

There must be something I am not understanding here.

I have a Submission model which is a mongo collection and it hasMany images which previously was also a mongo collection. I was using $submissions = Submission::has('images')->get(); and this was working fine, returning all submissions with at least one image.

Now I decided to convert my Image mongo collection to a mysql table and now it seems I can't use has() anymore

Submission.php

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

class Submission extends Eloquent
{
    protected $connection = 'mongodb';
    protected $collection = 'submissions';

    public function images()
    {
        return $this->hasMany('\App\Models\Image', "submission_id");
    }
}

Image.php

use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\HybridRelations;

class Image extends Model
{
    use HybridRelations;

    protected $connection = 'default';
    public $table = 'images';

    public function submission()
    {
        return $this->belongsTo('\App\Models\Submission', "submission_id");
    }
}

When I try to run my query I get

BadMethodCallException in Builder.php line 2508:
Call to undefined method Illuminate\Database\Query\Builder::getHasCompareKey()

Please someone help.. been trying to solve this for hours.

@vesper8
Copy link
Author

vesper8 commented Mar 30, 2017

anyone can help please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants