Skip to content

Commit

Permalink
feat: add role to authorities for items
Browse files Browse the repository at this point in the history
  • Loading branch information
FrantisekMichalSebestyen committed Aug 10, 2023
1 parent 3811cc0 commit d104d5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/Http/Resources/Api/V2/AuthorityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Resources\Api\V2;

use App\Authority;
use Illuminate\Http\Resources\Json\JsonResource;

class AuthorityResource extends JsonResource
Expand All @@ -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(),
];
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Api/V2/ItemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -51,6 +51,7 @@ public function test_detail()
'death_place',
'image_path',
]),
'role' => 'autor',
'image_path' => $authority->getImagePath(),
],
],
Expand Down

0 comments on commit d104d5a

Please sign in to comment.