Support the ongoing development of Laravel.io →
Eloquent
Last updated 3 months ago.
0

withTrashed returns all soft deleted users. I want all active users, plus the one that's (possibly) soft deleted. This works:

public function scopeActiveOr($query, $id){
    return $query->withTrashed()->where(function($q) use($id){
        $q->whereNull('deleted_at')
            ->orWhere('id', $id);
    });
}

But I'd like to not have to apply SoftDeletes, remove them, then reapply them. I thought there'd be a native solution.

Last updated 10 months ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

SMills SMills asdf072 Joined 3 Oct 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.