Remove old actions

This commit is contained in:
Philipp Lang 2023-12-17 21:24:16 +01:00
parent 2e8c41d5d9
commit 07a0c22a69
6 changed files with 0 additions and 208 deletions

View File

@ -1,42 +0,0 @@
<?php
namespace App\Payment\Actions;
use App\Lib\JobMiddleware\JobChannels;
use App\Lib\JobMiddleware\WithJobState;
use App\Lib\Queue\TracksJob;
use App\Payment\Payment;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\Concerns\AsAction;
class PaymentDestroyAction
{
use AsAction;
use TracksJob;
public function handle(int $paymentId): void
{
Payment::find($paymentId)->delete();
}
public function asController(Payment $payment): JsonResponse
{
$this->startJob($payment->id, $payment->member->fullname);
return response()->json([]);
}
/**
* @param mixed $parameters
*/
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
{
$memberName = $parameters[1];
return $jobState
->before('Zahlung für ' . $memberName . ' wird gelöscht')
->after('Zahlung für ' . $memberName . ' gelöscht')
->failed('Fehler beim Löschen der Zahlung für ' . $memberName)
->shouldReload(JobChannels::make()->add('member')->add('payment'));
}
}

View File

@ -1,58 +0,0 @@
<?php
namespace App\Payment\Actions;
use App\Lib\JobMiddleware\JobChannels;
use App\Lib\JobMiddleware\WithJobState;
use App\Lib\Queue\TracksJob;
use App\Member\Member;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class PaymentStoreAction
{
use AsAction;
use TracksJob;
/**
* @param array<string, string> $attributes
*/
public function handle(Member $member, array $attributes): void
{
$member->createPayment($attributes);
}
/**
* @return array<string, string>
*/
public function rules(): array
{
return [
'nr' => 'required',
'subscription_id' => 'required|exists:subscriptions,id',
'status_id' => 'required|exists:statuses,id',
];
}
public function asController(Member $member, ActionRequest $request): JsonResponse
{
$this->startJob($member, $request->validated());
return response()->json([]);
}
/**
* @param mixed $parameters
*/
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
{
$member = $parameters[0];
return $jobState
->before('Zahlung für ' . $member->fullname . ' wird gespeichert')
->after('Zahlung für ' . $member->fullname . ' gespeichert')
->failed('Fehler beim Erstellen der Zahlung für ' . $member->fullname)
->shouldReload(JobChannels::make()->add('member')->add('payment'));
}
}

View File

@ -1,58 +0,0 @@
<?php
namespace App\Payment\Actions;
use App\Lib\JobMiddleware\JobChannels;
use App\Lib\JobMiddleware\WithJobState;
use App\Lib\Queue\TracksJob;
use App\Payment\Payment;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
class PaymentUpdateAction
{
use AsAction;
use TracksJob;
/**
* @param array<string, string> $attributes
*/
public function handle(Payment $payment, array $attributes): void
{
$payment->update($attributes);
}
/**
* @return array<string, string>
*/
public function rules(): array
{
return [
'nr' => 'required',
'subscription_id' => 'required|exists:subscriptions,id',
'status_id' => 'required|exists:statuses,id',
];
}
public function asController(Payment $payment, ActionRequest $request): JsonResponse
{
$this->startJob($payment, $request->validated());
return response()->json([]);
}
/**
* @param mixed $parameters
*/
public function jobState(WithJobState $jobState, ...$parameters): WithJobState
{
$member = $parameters[0]->member;
return $jobState
->before('Zahlung für ' . $member->fullname . ' wird aktualisiert')
->after('Zahlung für ' . $member->fullname . ' aktualisiert')
->failed('Fehler beim Aktualisieren der Zahlung für ' . $member->fullname)
->shouldReload(JobChannels::make()->add('member')->add('payment'));
}
}

View File

@ -31,8 +31,6 @@ class PaymentResource extends JsonResource
'show' => $this->invoice_data
? route('payment.pdf', ['payment' => $this->getModel()])
: null,
'update' => route('payment.update', ['payment' => $this->getModel()]),
'destroy' => route('payment.destroy', ['payment' => $this->getModel()]),
]
];
}

View File

@ -109,9 +109,6 @@ Route::group(['middleware' => 'auth:web'], function (): void {
// ---------------------------------- payment ----------------------------------
Route::get('/payment/{payment}/pdf', DisplayPdfAction::class)->name('payment.pdf');
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');
// -------------------------------- allpayment ---------------------------------
Route::post('/invoice/mass-store', MassStoreAction::class)->name('invoice.mass-store');

View File

@ -1,45 +0,0 @@
<?php
namespace Tests\Feature\Payment;
use App\Lib\Events\JobFinished;
use App\Lib\Events\JobStarted;
use App\Lib\Events\ReloadTriggered;
use App\Member\Member;
use App\Payment\Status;
use App\Payment\Subscription;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class StoreTest extends TestCase
{
use DatabaseTransactions;
public function testItStoresAPayment(): void
{
Event::fake([JobStarted::class, JobFinished::class, ReloadTriggered::class]);
$this->withoutExceptionHandling()->login()->loginNami();
$subscription = Subscription::factory()->create();
$member = Member::factory()->defaults()->create();
$status = Status::factory()->create();
$this->post("/member/{$member->id}/payment", [
'status_id' => $status->id,
'subscription_id' => $subscription->id,
'nr' => '2019',
])->assertOk();
$this->assertDatabaseHas('payments', [
'member_id' => $member->id,
'status_id' => $status->id,
'subscription_id' => $subscription->id,
'nr' => '2019',
]);
Event::assertDispatched(JobStarted::class, fn ($event) => $event->broadcastOn()[0]->name === 'jobs' && $event->message !== null);
Event::assertDispatched(JobFinished::class, fn ($event) => $event->broadcastOn()[0]->name === 'jobs' && $event->message !== null);
Event::assertDispatched(ReloadTriggered::class, fn ($event) => ['member', 'payment'] === $event->channels->toArray());
}
}