mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for filters
This commit is contained in:
parent
076b14f0fa
commit
de8efd9faa
@ -154,23 +154,15 @@ class UserFilters extends QueryFilters
|
||||
$user = auth()->user();
|
||||
|
||||
if (in_array(self::STATUS_ACTIVE, $filters)) {
|
||||
$query = $query->orWhereHas('company_users', function ($q) use($user){
|
||||
$q->where('company_id', $user->company()->id)->whereNull('deleted_at');
|
||||
});
|
||||
$query->orWhereNull('deleted_at');
|
||||
}
|
||||
|
||||
if (in_array(self::STATUS_ARCHIVED, $filters)) {
|
||||
$query = $query->orWhereHas('company_users', function ($q) use($user){
|
||||
$q->where('company_id', $user->company()->id)->whereNotNull('deleted_at')->where('is_deleted', 0);
|
||||
});
|
||||
|
||||
$query->orWhereNotNull('deleted_at')->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
if (in_array(self::STATUS_DELETED, $filters)) {
|
||||
$query = $query->orWhereHas('company_users', function ($q) use($user){
|
||||
$q->where('company_id', $user->company()->id)->where('is_deleted', 1);
|
||||
});
|
||||
|
||||
$query->orWhere('is_deleted', 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class UserTest extends TestCase
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $company_token->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->get("/api/v1/users?without={$company_token->user->hashed_id}&status=active");
|
||||
])->get("/api/v1/users?status=active&without={$company_token->user->hashed_id}");
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertCount(0, $response->json()['data']);
|
||||
@ -204,7 +204,7 @@ class UserTest extends TestCase
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $company_token->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->get("/api/v1/users?without={$company_token->user->hashed_id}&status=archived");
|
||||
])->get("/api/v1/users?status=archived&without={$company_token->user->hashed_id}");
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertCount(1, $response->json()['data']);
|
||||
@ -213,7 +213,7 @@ class UserTest extends TestCase
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $company_token->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->get("/api/v1/users?without={$company_token->user->hashed_id}&status=deleted");
|
||||
])->get("/api/v1/users?status=deleted&without={$company_token->user->hashed_id}");
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertCount(0, $response->json()['data']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user