laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Calling scopes after relationships not recognized.

Open nickaguilarh opened this issue 3 years ago • 16 comments

Versions:

  • ide-helper Version: 2.8.1
  • Laravel Version: 8.9.0
  • PHP Version: 7.4.10

Question:

Hi there, I've been using this package for a long time now and I just noticed that when calling a scope from a relationship it is not detected. Is it the correct behavior?

Example: Email.php

    public function mails(): BelongsToMany
    {
        return $this->belongsToMany(Mail::class);
    }

    public function scopeValid(Builder $query): Builder
    {
        return $query->where('status', '<>', 'blocked');
    }

Mail.php

    public function emails(): BelongsToMany
    {
        return $this->belongsToMany(Email::class);
    }

Usage

    $mail->emails()->active()->get()

image

nickaguilarh avatar Oct 29 '20 04:10 nickaguilarh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jan 30 '21 11:01 stale[bot]

Same issue here

chescos avatar Feb 19 '21 23:02 chescos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jun 01 '21 09:06 stale[bot]

this issue is still present :/

eli-s-r avatar Jun 01 '21 15:06 eli-s-r

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Sep 03 '21 09:09 stale[bot]

Still present

eli-s-r avatar Sep 03 '21 15:09 eli-s-r

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jan 03 '22 21:01 stale[bot]

Still present

chescos avatar Jan 03 '22 21:01 chescos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Apr 16 '22 12:04 stale[bot]

Still present

chescos avatar Apr 16 '22 12:04 chescos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jul 31 '22 12:07 stale[bot]

Still present

chescos avatar Jul 31 '22 12:07 chescos

Still present. I am using latest master branch

Lapinskas avatar Sep 12 '22 15:09 Lapinskas

public function emails(): BelongsToMany | Email
    {
        return $this->belongsToMany(Email::class);
    }

This will do.

terranc avatar Dec 07 '22 04:12 terranc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jun 18 '23 08:06 stale[bot]

I'm also running into this:

On Events

public function scheduleSessions(): HasMany|Session
    {
        return $this->hasMany(Session::class)->whereNull('schedule_session_id')->whereNull('lift_id');
    }

On Session

public function scopeSorted($query): Builder
    {
        return $query->orderBy('gender_id')
            ->orderBy('age_id')
            ->orderBy('child_age_id')
            ->orderBy('session_letter');
    }

In use

$scheduleSessions = $this->scheduleSessions()
            ->with(['scheduleDivisionSessions'])
            ->sorted()
            ->get();

Method 'sorted' not found in \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Relations\HasMany

CitizenBeta avatar Aug 25 '23 03:08 CitizenBeta