Support the ongoing development of Laravel.io →
posted 3 years ago
Eloquent
Last updated 2 years 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 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

SMills asdf072 Joined 3 Oct 2021

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.