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

Should findBySlugOrFail return Model instead? #596

Closed
WalrusSoup opened this issue Feb 20, 2023 · 1 comment
Closed

Should findBySlugOrFail return Model instead? #596

WalrusSoup opened this issue Feb 20, 2023 · 1 comment

Comments

@WalrusSoup
Copy link

Running into an oddity with larastan, which reports this:

Access to an undefined property Illuminate\Database\Eloquent\Collection|Illuminate\Database\Eloquent\Model::$id.

when calling the function findBySlugOrFail

this function has a docblock which says it can return a collection:

@return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection

however, I don't believe this is capable of returning a collection due to underlying call only returning an instance of a model or throwing:

return static::whereSlug($slug)->firstOrFail($columns);
@cviebrock
Copy link
Owner

Thanks! Fixed this and it'll go out in the next release.

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