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

Url::scopeDefault() types QueryBuilder instead of EloquentBuilder #1728

Closed
adevade opened this issue May 8, 2024 · 2 comments · Fixed by #1766
Closed

Url::scopeDefault() types QueryBuilder instead of EloquentBuilder #1728

adevade opened this issue May 8, 2024 · 2 comments · Fixed by #1766
Assignees
Labels
1.x bug Something isn't working

Comments

@adevade
Copy link
Contributor

adevade commented May 8, 2024

  • Lunar version: 1.0.0-alpha.17
  • Laravel Version: 11.7.0
  • PHP Version: 8.3.6
  • Database Driver & Version: SQLite 3.45

Expected Behaviour:

When calling Url::default()->first() I get an error because the wrong class is typed in the scopeDefault() method.

Switch use Illuminate\Database\Query\Builder; for use Illuminate\Database\Eloquent\Builder; in the use statements.

Actual Behaviour:

> Lunar\Models\Url::default()->where('slug', 't-shirt')->first()
 
  TypeError Lunar\Models\Url::scopeDefault(): Argument #1 ($query) must be of type Illuminate\Database\Query\Builder, Illuminate\Database\Eloquent\Builder given, called in vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1631.

Steps To Reproduce:

\Lunar\Models\Url::default()->first();
@alecritson
Copy link
Collaborator

Thanks @adevade There's now a PR for this and should be done in the next release :)

@adevade
Copy link
Contributor Author

adevade commented May 21, 2024

Awesome! I was going to send a PR myself, but was just wrapping up for the day when i discovered the bug, so I just created an issue and then I forgot about it 🙈

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants