diff --git a/app/Invoice/Enums/InvoiceStatus.php b/app/Invoice/Enums/InvoiceStatus.php index 54432afa..2faf36ad 100644 --- a/app/Invoice/Enums/InvoiceStatus.php +++ b/app/Invoice/Enums/InvoiceStatus.php @@ -17,4 +17,12 @@ enum InvoiceStatus: string { return collect(static::cases())->map(fn ($case) => $case->value); } + + /** + * @return array + */ + public static function forSelect(): array + { + return array_map(fn ($case) => ['id' => $case->value, 'name' => $case->value], static::cases()); + } } diff --git a/app/Invoice/Resources/InvoiceResource.php b/app/Invoice/Resources/InvoiceResource.php index 967c1009..9d4e6ffe 100644 --- a/app/Invoice/Resources/InvoiceResource.php +++ b/app/Invoice/Resources/InvoiceResource.php @@ -2,6 +2,8 @@ namespace App\Invoice\Resources; +use App\Invoice\BillKind; +use App\Invoice\Enums\InvoiceStatus; use App\Invoice\Models\Invoice; use App\Lib\HasMeta; use Illuminate\Http\Resources\Json\JsonResource; @@ -39,7 +41,9 @@ class InvoiceResource extends JsonResource return [ 'links' => [ 'mass-store' => route('invoice.mass-store'), - ] + ], + 'vias' => BillKind::forSelect(), + 'statuses' => InvoiceStatus::forSelect(), ]; } } diff --git a/tests/Feature/Invoice/InvoiceIndexActionTest.php b/tests/Feature/Invoice/InvoiceIndexActionTest.php index d0860bd4..665bd0c5 100644 --- a/tests/Feature/Invoice/InvoiceIndexActionTest.php +++ b/tests/Feature/Invoice/InvoiceIndexActionTest.php @@ -32,7 +32,9 @@ class InvoiceIndexActionTest extends TestCase ->assertInertiaPath('data.data.0.sent_at_human', now()->subDay()->format('d.m.Y')) ->assertInertiaPath('data.data.0.status', 'Rechnung gestellt') ->assertInertiaPath('data.data.0.via', 'Post') - ->assertInertiaPath('data.meta.links.mass-store', route('invoice.mass-store')); + ->assertInertiaPath('data.meta.links.mass-store', route('invoice.mass-store')) + ->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail']) + ->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu']); } public function testValuesCanBeNull(): void