Add member meta to InvoiceResource
This commit is contained in:
parent
5a87d3e7f6
commit
ebeb9bc0b0
app
tests/Feature/Invoice
|
@ -6,6 +6,7 @@ use App\Invoice\BillKind;
|
||||||
use App\Invoice\Enums\InvoiceStatus;
|
use App\Invoice\Enums\InvoiceStatus;
|
||||||
use App\Invoice\Models\Invoice;
|
use App\Invoice\Models\Invoice;
|
||||||
use App\Lib\HasMeta;
|
use App\Lib\HasMeta;
|
||||||
|
use App\Member\Member;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +46,7 @@ class InvoiceResource extends JsonResource
|
||||||
],
|
],
|
||||||
'vias' => BillKind::forSelect(),
|
'vias' => BillKind::forSelect(),
|
||||||
'statuses' => InvoiceStatus::forSelect(),
|
'statuses' => InvoiceStatus::forSelect(),
|
||||||
|
'members' => Member::forSelect(),
|
||||||
'default' => [
|
'default' => [
|
||||||
'to' => [
|
'to' => [
|
||||||
'name' => '',
|
'name' => '',
|
||||||
|
@ -60,6 +62,7 @@ class InvoiceResource extends JsonResource
|
||||||
'default_position' => [
|
'default_position' => [
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
'description' => '',
|
'description' => '',
|
||||||
|
'member_id' => null,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,6 +494,14 @@ class Member extends Model implements Geolocatable
|
||||||
])->implode(' ');
|
])->implode(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{id: int, name: string}>
|
||||||
|
*/
|
||||||
|
public static function forSelect(): array
|
||||||
|
{
|
||||||
|
return static::select(['id', 'firstname', 'lastname'])->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname])->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------- Geolocation --------------------------------
|
// -------------------------------- Geolocation --------------------------------
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
public function fillCoordinate(Coordinate $coordinate): void
|
public function fillCoordinate(Coordinate $coordinate): void
|
||||||
|
|
|
@ -17,6 +17,7 @@ class InvoiceIndexActionTest extends TestCase
|
||||||
public function testItDisplaysInvoices(): void
|
public function testItDisplaysInvoices(): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
|
$member = Member::factory()->defaults()->create(['firstname' => 'Aaaa', 'lastname' => 'Aaab']);
|
||||||
Invoice::factory()
|
Invoice::factory()
|
||||||
->has(InvoicePosition::factory()->price(1100), 'positions')
|
->has(InvoicePosition::factory()->price(1100), 'positions')
|
||||||
->has(InvoicePosition::factory()->price(2200), 'positions')
|
->has(InvoicePosition::factory()->price(2200), 'positions')
|
||||||
|
@ -36,6 +37,7 @@ class InvoiceIndexActionTest extends TestCase
|
||||||
->assertInertiaPath('data.meta.links.store', route('invoice.store'))
|
->assertInertiaPath('data.meta.links.store', route('invoice.store'))
|
||||||
->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail'])
|
->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail'])
|
||||||
->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu'])
|
->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu'])
|
||||||
|
->assertInertiaPath('data.meta.members.0', ['id' => $member->id, 'name' => 'Aaaa Aaab'])
|
||||||
->assertInertiaPath('data.meta.default', [
|
->assertInertiaPath('data.meta.default', [
|
||||||
'to' => [
|
'to' => [
|
||||||
'name' => '',
|
'name' => '',
|
||||||
|
|
Loading…
Reference in New Issue