Add meta for InvoiceIndex
This commit is contained in:
parent
5b6380b429
commit
380c18a70e
|
@ -17,4 +17,12 @@ enum InvoiceStatus: string
|
||||||
{
|
{
|
||||||
return collect(static::cases())->map(fn ($case) => $case->value);
|
return collect(static::cases())->map(fn ($case) => $case->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{id: string, name: string}>
|
||||||
|
*/
|
||||||
|
public static function forSelect(): array
|
||||||
|
{
|
||||||
|
return array_map(fn ($case) => ['id' => $case->value, 'name' => $case->value], static::cases());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Invoice\Resources;
|
namespace App\Invoice\Resources;
|
||||||
|
|
||||||
|
use App\Invoice\BillKind;
|
||||||
|
use App\Invoice\Enums\InvoiceStatus;
|
||||||
use App\Invoice\Models\Invoice;
|
use App\Invoice\Models\Invoice;
|
||||||
use App\Lib\HasMeta;
|
use App\Lib\HasMeta;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
@ -39,7 +41,9 @@ class InvoiceResource extends JsonResource
|
||||||
return [
|
return [
|
||||||
'links' => [
|
'links' => [
|
||||||
'mass-store' => route('invoice.mass-store'),
|
'mass-store' => route('invoice.mass-store'),
|
||||||
]
|
],
|
||||||
|
'vias' => BillKind::forSelect(),
|
||||||
|
'statuses' => InvoiceStatus::forSelect(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.sent_at_human', now()->subDay()->format('d.m.Y'))
|
||||||
->assertInertiaPath('data.data.0.status', 'Rechnung gestellt')
|
->assertInertiaPath('data.data.0.status', 'Rechnung gestellt')
|
||||||
->assertInertiaPath('data.data.0.via', 'Post')
|
->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
|
public function testValuesCanBeNull(): void
|
||||||
|
|
Loading…
Reference in New Issue