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(), ], ],