Add payment index
This commit is contained in:
parent
8846adef5b
commit
c764f3d3b7
|
@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class ApiIndexAction
|
class IndexAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Validation\Rules\In;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PaymentDestroyAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string|In>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getValidationAttributes(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Validation\Rules\In;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PaymentStoreAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string|In>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getValidationAttributes(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Payment\Actions;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Validation\Rules\In;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class PaymentUpdateAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string|In>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getValidationAttributes(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function asController(): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,8 +28,8 @@ class PaymentResource extends JsonResource
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'is_accepted' => $this->status->isAccepted(),
|
'is_accepted' => $this->status->isAccepted(),
|
||||||
'links' => [
|
'links' => [
|
||||||
'update' => route('member.payment.update', ['payment' => $this->getModel(), 'member' => $this->getModel()->member]),
|
'update' => route('payment.update', ['payment' => $this->getModel()]),
|
||||||
'destroy' => route('member.payment.destroy', ['payment' => $this->getModel(), 'member' => $this->getModel()->member]),
|
'destroy' => route('payment.destroy', ['payment' => $this->getModel()]),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,10 @@ use App\Membership\Actions\MembershipUpdateAction;
|
||||||
use App\Membership\Actions\StoreForGroupAction;
|
use App\Membership\Actions\StoreForGroupAction;
|
||||||
use App\Payment\Actions\AllpaymentPageAction;
|
use App\Payment\Actions\AllpaymentPageAction;
|
||||||
use App\Payment\Actions\AllpaymentStoreAction;
|
use App\Payment\Actions\AllpaymentStoreAction;
|
||||||
use App\Payment\Actions\ApiIndexAction as PaymentApiIndexAction;
|
use App\Payment\Actions\IndexAction as PaymentIndexAction;
|
||||||
use App\Payment\PaymentController;
|
use App\Payment\Actions\PaymentDestroyAction;
|
||||||
|
use App\Payment\Actions\PaymentStoreAction;
|
||||||
|
use App\Payment\Actions\PaymentUpdateAction;
|
||||||
use App\Payment\SendpaymentController;
|
use App\Payment\SendpaymentController;
|
||||||
use App\Payment\SubscriptionController;
|
use App\Payment\SubscriptionController;
|
||||||
use App\Pdf\MemberPdfController;
|
use App\Pdf\MemberPdfController;
|
||||||
|
@ -104,8 +106,10 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
||||||
Route::get('/group', ListAction::class)->name('group.index');
|
Route::get('/group', ListAction::class)->name('group.index');
|
||||||
|
|
||||||
// ---------------------------------- payment ----------------------------------
|
// ---------------------------------- payment ----------------------------------
|
||||||
Route::apiResource('member.payment', PaymentController::class);
|
Route::get('/member/{member}/payment', PaymentIndexAction::class)->name('member.payment.index');
|
||||||
Route::post('/api/member/{member}/payment', PaymentApiIndexAction::class)->name('member.payment.index');
|
Route::post('/member/{member}/payment', PaymentStoreAction::class)->name('member.payment.store');
|
||||||
|
Route::patch('/payment/{payment}', PaymentUpdateAction::class)->name('payment.update');
|
||||||
|
Route::delete('/payment/{payment}', PaymentDestroyAction::class)->name('payment.destroy');
|
||||||
|
|
||||||
// --------------------------------- membership --------------------------------
|
// --------------------------------- membership --------------------------------
|
||||||
Route::get('/member/{member}/membership', MembershipIndexAction::class)->name('member.membership.index');
|
Route::get('/member/{member}/membership', MembershipIndexAction::class)->name('member.membership.index');
|
||||||
|
|
|
@ -37,7 +37,7 @@ class IndexTest extends TestCase
|
||||||
$this->assertInertiaHas($group->id, $response, 'data.data.0.group_id');
|
$this->assertInertiaHas($group->id, $response, 'data.data.0.group_id');
|
||||||
$this->assertInertiaHas(null, $response, 'data.data.0.memberships');
|
$this->assertInertiaHas(null, $response, 'data.data.0.memberships');
|
||||||
$this->assertInertiaHas(url("/member/{$member->id}/membership"), $response, 'data.data.0.links.membership_index');
|
$this->assertInertiaHas(url("/member/{$member->id}/membership"), $response, 'data.data.0.links.membership_index');
|
||||||
$this->assertInertiaHas(url("/api/member/{$member->id}/payment"), $response, 'data.data.0.links.payment_index');
|
$this->assertInertiaHas(url("/member/{$member->id}/payment"), $response, 'data.data.0.links.payment_index');
|
||||||
$this->assertInertiaHas([
|
$this->assertInertiaHas([
|
||||||
'id' => $member->subscription->id,
|
'id' => $member->subscription->id,
|
||||||
'name' => $member->subscription->name,
|
'name' => $member->subscription->name,
|
||||||
|
|
|
@ -25,15 +25,15 @@ class IndexTest extends TestCase
|
||||||
->defaults()->create();
|
->defaults()->create();
|
||||||
$payment = $member->payments->first();
|
$payment = $member->payments->first();
|
||||||
|
|
||||||
$this->postJson("/api/member/{$member->id}/payment")
|
$this->get("/member/{$member->id}/payment")
|
||||||
->assertJsonPath('data.0.subscription.name', 'Free')
|
->assertJsonPath('data.0.subscription.name', 'Free')
|
||||||
->assertJsonPath('data.0.subscription.id', $payment->subscription->id)
|
->assertJsonPath('data.0.subscription.id', $payment->subscription->id)
|
||||||
->assertJsonPath('data.0.subscription.amount', 1050)
|
->assertJsonPath('data.0.subscription.amount', 1050)
|
||||||
->assertJsonPath('data.0.subscription_id', $payment->subscription->id)
|
->assertJsonPath('data.0.subscription_id', $payment->subscription->id)
|
||||||
->assertJsonPath('data.0.status_name', 'Nicht bezahlt')
|
->assertJsonPath('data.0.status_name', 'Nicht bezahlt')
|
||||||
->assertJsonPath('data.0.nr', '2019')
|
->assertJsonPath('data.0.nr', '2019')
|
||||||
->assertJsonPath('data.0.links.update', url("/member/{$member->id}/payment/{$payment->id}"))
|
->assertJsonPath('data.0.links.update', url("/payment/{$payment->id}"))
|
||||||
->assertJsonPath('data.0.links.destroy', url("/member/{$member->id}/payment/{$payment->id}"))
|
->assertJsonPath('data.0.links.destroy', url("/payment/{$payment->id}"))
|
||||||
->assertJsonPath('meta.statuses.0.name', 'Nicht bezahlt')
|
->assertJsonPath('meta.statuses.0.name', 'Nicht bezahlt')
|
||||||
->assertJsonPath('meta.statuses.0.id', $payment->status->id)
|
->assertJsonPath('meta.statuses.0.id', $payment->status->id)
|
||||||
->assertJsonPath('meta.subscriptions.0.id', Subscription::first()->id)
|
->assertJsonPath('meta.subscriptions.0.id', Subscription::first()->id)
|
||||||
|
|
Loading…
Reference in New Issue