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

fix eloquent generics documentation #2008

Closed
wants to merge 1 commit into from
Closed

Conversation

arxeiss
Copy link
Contributor

@arxeiss arxeiss commented Jul 27, 2024

  • Added or updated tests
  • Documented user facing changes

Changes

The documentation mention, we should be using BelongsTo<Model, $this> but when I use it, I got this error (stripped own FQDN)

Method Absence::user() should return
Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this(Absence)> but returns  
Illuminate\Database\Eloquent\Relations\BelongsTo<User, Absence>

After changing $this to self it works well.

Breaking changes

None

@Afrowson
Copy link

Afrowson commented Oct 18, 2024

For me this works:

 /**
  * @return HasMany<BookingDetail, $this>
  */
 public function bookingDetails(): HasMany
 {
     return $this->hasMany(BookingDetail::class, 'bookings_id');
 }

@calebdw
Copy link
Contributor

calebdw commented Oct 18, 2024

Yeah, this PR can be closed now

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

Successfully merging this pull request may close these issues.

4 participants