fixed: filter only for active memberships
continuous-integration/drone/push Build was killed Details

This commit is contained in:
philipp lang 2023-02-23 01:30:31 +01:00
parent 44876ed6bd
commit 9afa34504c
2 changed files with 4 additions and 2 deletions

View File

@ -392,6 +392,7 @@ class Member extends Model
}
if (data_get($filter, 'subactivity_id', false) || data_get($filter, 'activity_id', false)) {
$query->whereHas('memberships', function ($q) use ($filter) {
$q->active();
if (data_get($filter, 'subactivity_id', false)) {
$q->where('subactivity_id', $filter['subactivity_id']);
}

View File

@ -136,8 +136,8 @@ class IndexTest extends TestCase
public function testItCanFilterForBillKinds(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$emailMember = Member::factory()->defaults()->emailBillKind()->create();
$postMember = Member::factory()->defaults()->postBillKind()->create();
Member::factory()->defaults()->emailBillKind()->create();
Member::factory()->defaults()->postBillKind()->create();
$emailResponse = $this->call('GET', '/member', ['filter' => '{"bill_kind": "E-Mail"}']);
$postResponse = $this->call('GET', '/member', ['filter' => '{"bill_kind": "Post"}']);
@ -145,4 +145,5 @@ class IndexTest extends TestCase
$this->assertCount(1, $this->inertia($emailResponse, 'data.data'));
$this->assertCount(1, $this->inertia($postResponse, 'data.data'));
}
}