From d104d5a7c69bcdbfd53ade90ae45d250a4dee5f0 Mon Sep 17 00:00:00 2001 From: FrantisekMichalSebestyen Date: Thu, 10 Aug 2023 14:48:42 +0200 Subject: [PATCH] feat: add role to authorities for items --- app/Http/Resources/Api/V2/AuthorityResource.php | 2 ++ tests/Feature/Api/V2/ItemsTest.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Resources/Api/V2/AuthorityResource.php b/app/Http/Resources/Api/V2/AuthorityResource.php index 22410bda9..b91c4a34b 100644 --- a/app/Http/Resources/Api/V2/AuthorityResource.php +++ b/app/Http/Resources/Api/V2/AuthorityResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources\Api\V2; +use App\Authority; use Illuminate\Http\Resources\Json\JsonResource; class AuthorityResource extends JsonResource @@ -23,6 +24,7 @@ public function toArray($request) 'death_place' => $this->death_place, 'birth_date' => $this->birth_date, 'death_date' => $this->death_date, + 'role' => Authority::formatMultiAttribute($this->pivot->role), 'image_path' => $this->getImagePath(), ]; } diff --git a/tests/Feature/Api/V2/ItemsTest.php b/tests/Feature/Api/V2/ItemsTest.php index 2459ce256..c82abbb83 100644 --- a/tests/Feature/Api/V2/ItemsTest.php +++ b/tests/Feature/Api/V2/ItemsTest.php @@ -28,7 +28,7 @@ public function test_detail() 'image_ratio' => 1.5, ]); - $item->authorities()->attach($authority); + $item->authorities()->attach($authority, ['role' => 'autor/author']); $item_image->item()->associate($item); $item_image->save(); @@ -51,6 +51,7 @@ public function test_detail() 'death_place', 'image_path', ]), + 'role' => 'autor', 'image_path' => $authority->getImagePath(), ], ],