Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:11.xfrom
utsavsomaiya:feature/add-withWhereRelation-method
Feb 18, 2025
Merged

[11.x] Add withWhereRelation method to builder#54668
taylorotwell merged 2 commits into
laravel:11.xfrom
utsavsomaiya:feature/add-withWhereRelation-method

Conversation

@utsavsomaiya

Copy link
Copy Markdown
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
@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.

2 participants