You can use the withTrashed method.
https://laravel.com/docs/8.x/eloquent#querying-soft-deleted-models
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community