Skip to content

[11.x] Add withWhereRelation method to builder #54668

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

Merged

Conversation

utsavsomaiya
Copy link
Contributor

class Consumer extends Model
{
    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class)->withTrashed();
    }
}
Consumer::query()
-    ->withWhereHas('company', function (Builder|BelongsTo $query): void {
-       $query->whereNull('deleted_at');
-   })
+    ->withWhereRelation('company', 'deleted_at' null);

@utsavsomaiya utsavsomaiya force-pushed the feature/add-withWhereRelation-method branch from ab068f5 to 2362ed4 Compare February 18, 2025 09:38
@taylorotwell taylorotwell merged commit d1b8c89 into laravel:11.x Feb 18, 2025
21 of 22 checks passed
@utsavsomaiya utsavsomaiya deleted the feature/add-withWhereRelation-method branch February 18, 2025 15:36
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.

None yet

2 participants