From 4cb2dddb435603d660bd4399fc1a9f5f15c49c64 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 7 Mar 2023 00:27:10 +0100 Subject: [PATCH] Return is_filterable for subactivity --- app/Activity/Resources/ActivityResource.php | 2 +- app/Subactivity.php | 1 + tests/Feature/Activity/EditTest.php | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Activity/Resources/ActivityResource.php b/app/Activity/Resources/ActivityResource.php index 1084e55d..123a5f8c 100644 --- a/app/Activity/Resources/ActivityResource.php +++ b/app/Activity/Resources/ActivityResource.php @@ -49,7 +49,7 @@ class ActivityResource extends JsonResource public static function meta(): array { return [ - 'subactivities' => Subactivity::select('name', 'id')->get(), + 'subactivities' => Subactivity::select('name', 'id', 'is_filterable')->get(), 'filter' => ActivityFilterScope::fromRequest(request()->input('filter')), ]; } diff --git a/app/Subactivity.php b/app/Subactivity.php index 723a9ce7..78aea4ec 100644 --- a/app/Subactivity.php +++ b/app/Subactivity.php @@ -20,6 +20,7 @@ class Subactivity extends Model public $casts = [ 'is_age_group' => 'boolean', + 'is_filterable' => 'boolean', ]; public function sluggable(): array diff --git a/tests/Feature/Activity/EditTest.php b/tests/Feature/Activity/EditTest.php index d7cc5657..b41ec286 100644 --- a/tests/Feature/Activity/EditTest.php +++ b/tests/Feature/Activity/EditTest.php @@ -14,7 +14,7 @@ class EditTest extends TestCase public function testItEditsAnActivity(): void { $this->login()->loginNami()->withoutExceptionHandling(); - $activity = Activity::factory()->name('Asas')->hasAttached(Subactivity::factory()->name('Pupu'))->create(); + $activity = Activity::factory()->name('Asas')->hasAttached(Subactivity::factory()->name('Pupu')->filterable())->create(); $response = $this->get(route('activity.edit', ['activity' => $activity])); @@ -32,6 +32,7 @@ class EditTest extends TestCase $this->assertInertiaHas([ 'id' => $activity->subactivities->first()->id, 'name' => 'Pupu', + 'is_filterable' => true, ], $response, 'meta.subactivities.0'); } }