mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 23:34:36 -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();
|
$user = auth()->user();
|
||||||
|
|
||||||
if (in_array(self::STATUS_ACTIVE, $filters)) {
|
if (in_array(self::STATUS_ACTIVE, $filters)) {
|
||||||
$query = $query->orWhereHas('company_users', function ($q) use($user){
|
$query->orWhereNull('deleted_at');
|
||||||
$q->where('company_id', $user->company()->id)->whereNull('deleted_at');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(self::STATUS_ARCHIVED, $filters)) {
|
if (in_array(self::STATUS_ARCHIVED, $filters)) {
|
||||||
$query = $query->orWhereHas('company_users', function ($q) use($user){
|
$query->orWhereNotNull('deleted_at')->where('is_deleted', 0);
|
||||||
$q->where('company_id', $user->company()->id)->whereNotNull('deleted_at')->where('is_deleted', 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(self::STATUS_DELETED, $filters)) {
|
if (in_array(self::STATUS_DELETED, $filters)) {
|
||||||
$query = $query->orWhereHas('company_users', function ($q) use($user){
|
$query->orWhere('is_deleted', 1);
|
||||||
$q->where('company_id', $user->company()->id)->where('is_deleted', 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class UserTest extends TestCase
|
|||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $company_token->token,
|
'X-API-TOKEN' => $company_token->token,
|
||||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
'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);
|
$response->assertStatus(200);
|
||||||
$this->assertCount(0, $response->json()['data']);
|
$this->assertCount(0, $response->json()['data']);
|
||||||
@ -204,7 +204,7 @@ class UserTest extends TestCase
|
|||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $company_token->token,
|
'X-API-TOKEN' => $company_token->token,
|
||||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
'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);
|
$response->assertStatus(200);
|
||||||
$this->assertCount(1, $response->json()['data']);
|
$this->assertCount(1, $response->json()['data']);
|
||||||
@ -213,7 +213,7 @@ class UserTest extends TestCase
|
|||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $company_token->token,
|
'X-API-TOKEN' => $company_token->token,
|
||||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
'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);
|
$response->assertStatus(200);
|
||||||
$this->assertCount(0, $response->json()['data']);
|
$this->assertCount(0, $response->json()['data']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user