Skip to content
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

BaseEloquentRepository allWithBuilder() Error #487

Closed
darron1217 opened this issue Mar 9, 2018 · 2 comments
Closed

BaseEloquentRepository allWithBuilder() Error #487

darron1217 opened this issue Mar 9, 2018 · 2 comments

Comments

@darron1217
Copy link
Contributor

Summary of issue

Type error: Return value of Modules\Core\Repositories\Eloquent\EloquentBaseRepository::allWithBuilder() must be an instance of Illuminate\Database\Eloquent\Builder, instance of Modules\{ModuleName}\Entities\{ModelName} returned

{ModuleName} and {ModelName} is just sample name.

I got an error while calling allWithBuilder() of my own repository. (Which extends BaseRepository without any overriding)

I looked into the error and I found that this method returns return $this->model;
Just like the link below

Maybe we should change this method into return $this->model->query(); to avoid error

Steps to reproduce

System Details

  • Operating System
  • PHP Version
  • Laravel Version
  • Asgardcms/Platform version
@nWidart
Copy link
Member

nWidart commented Mar 9, 2018

Hm interesting, this worked before.

Indeed I think the query() method does return the correct type.

@darron1217
Copy link
Contributor Author

darron1217 commented Mar 9, 2018

@nWidart I think if we use Translatable Model, we can avoid this error.
I was using it well too :)

        if (method_exists($this->model, 'translations')) {
            return $this->model->with('translations');
        }

nWidart added a commit that referenced this issue Mar 9, 2018
Fix issue #487 (allWithBuilder error)
nWidart pushed a commit that referenced this issue Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants