diff --git a/app/Setting/SettingIndexAction.php b/app/Bill/SettingIndexAction.php similarity index 58% rename from app/Setting/SettingIndexAction.php rename to app/Bill/SettingIndexAction.php index 8fa467ca..07ff0beb 100644 --- a/app/Setting/SettingIndexAction.php +++ b/app/Bill/SettingIndexAction.php @@ -1,7 +1,8 @@ $settings->from_long, - 'bill_from' => $settings->from, - 'bill_mobile' => $settings->mobile, - 'bill_email' => $settings->email, - 'bill_website' => $settings->website, - 'bill_address' => $settings->address, - 'bill_place' => $settings->place, - 'bill_zip' => $settings->zip, + 'from_long' => $settings->from_long, + 'from' => $settings->from, + 'mobile' => $settings->mobile, + 'email' => $settings->email, + 'website' => $settings->website, + 'address' => $settings->address, + 'place' => $settings->place, + 'zip' => $settings->zip, ]; } diff --git a/app/Bill/SettingSaveAction.php b/app/Bill/SettingSaveAction.php new file mode 100644 index 00000000..fc862f02 --- /dev/null +++ b/app/Bill/SettingSaveAction.php @@ -0,0 +1,41 @@ + $input + */ + public function handle(array $input): void + { + $settings = app(BillSettings::class); + + $settings->fill([ + 'from_long' => $input['from_long'] ?? '', + 'from' => $input['from'] ?? '', + 'mobile' => $input['mobile'] ?? '', + 'email' => $input['email'] ?? '', + 'website' => $input['website'] ?? '', + 'address' => $input['address'] ?? '', + 'place' => $input['place'] ?? '', + 'zip' => $input['zip'] ?? '', + ]); + + $settings->save(); + } + + public function asController(ActionRequest $request): RedirectResponse + { + $this->handle($request->all()); + + return redirect()->back()->success('Einstellungen gespeichert'); + } +} diff --git a/app/Setting/SettingSaveAction.php b/app/Setting/SettingSaveAction.php deleted file mode 100644 index 6e963b97..00000000 --- a/app/Setting/SettingSaveAction.php +++ /dev/null @@ -1,34 +0,0 @@ -from_long = $input['bill_from_long'] ?? ''; - $settings->from = $input['bill_from'] ?? ''; - $settings->mobile = $input['bill_mobile'] ?? ''; - $settings->email = $input['bill_email'] ?? ''; - $settings->website = $input['bill_website'] ?? ''; - $settings->address = $input['bill_address'] ?? ''; - $settings->place = $input['bill_place'] ?? ''; - $settings->zip = $input['bill_zip'] ?? ''; - $settings->save(); - } - - public function asController(ActionRequest $request): RedirectResponse - { - $this->handle($request->all()); - - return redirect()->back()->success('Einstellungen gespeichert'); - } -} diff --git a/routes/web.php b/routes/web.php index 168d720c..4315d2be 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,7 @@ 'App\\Http\\Controllers'], function (): void { Auth::routes(['register' => false]); @@ -36,8 +36,8 @@ Route::group(['middleware' => 'auth:web'], function (): void { Route::get('/sendpayment', [SendpaymentController::class, 'create'])->name('sendpayment.create'); Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf'); Route::apiResource('member.membership', MembershipController::class); - Route::get('setting', SettingIndexAction::class); - Route::post('setting', SettingSaveAction::class); + Route::get('setting/bill', BillSettingIndexAction::class); + Route::post('setting/bill', BillSettingSaveAction::class); Route::resource('member.course', CourseController::class); Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz'); Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync'); diff --git a/tests/Feature/Setting/SettingTest.php b/tests/Feature/Setting/SettingTest.php index 400ea15f..5273e10f 100644 --- a/tests/Feature/Setting/SettingTest.php +++ b/tests/Feature/Setting/SettingTest.php @@ -24,18 +24,18 @@ class SettingTest extends TestCase 'zip' => '12345', ]); - $response = $this->get('/setting'); + $response = $this->get('/setting/bill'); $response->assertOk(); $this->assertInertiaHas([ - 'bill_from_long' => 'DPSG Stamm Muster', - 'bill_from' => 'Stamm Muster', - 'bill_mobile' => '+49 176 55555', - 'bill_email' => 'max@muster.de', - 'bill_website' => 'https://example.com', - 'bill_address' => 'Musterstr 4', - 'bill_place' => 'Solingen', - 'bill_zip' => '12345', + 'from_long' => 'DPSG Stamm Muster', + 'from' => 'Stamm Muster', + 'mobile' => '+49 176 55555', + 'email' => 'max@muster.de', + 'website' => 'https://example.com', + 'address' => 'Musterstr 4', + 'place' => 'Solingen', + 'zip' => '12345', ], $response, 'data'); } @@ -43,18 +43,18 @@ class SettingTest extends TestCase { $this->withoutExceptionHandling()->login()->loginNami(); - $response = $this->from('/setting')->post('/setting', [ - 'bill_from_long' => 'DPSG Stamm Muster', - 'bill_from' => 'Stamm Muster', - 'bill_mobile' => '+49 176 55555', - 'bill_email' => 'max@muster.de', - 'bill_website' => 'https://example.com', - 'bill_address' => 'Musterstr 4', - 'bill_place' => 'Solingen', - 'bill_zip' => '12345', + $response = $this->from('/setting/bill')->post('/setting/bill', [ + 'from_long' => 'DPSG Stamm Muster', + 'from' => 'Stamm Muster', + 'mobile' => '+49 176 55555', + 'email' => 'max@muster.de', + 'website' => 'https://example.com', + 'address' => 'Musterstr 4', + 'place' => 'Solingen', + 'zip' => '12345', ]); - $response->assertRedirect('/setting'); + $response->assertRedirect('/setting/bill'); $settings = app(BillSettings::class); $this->assertEquals('DPSG Stamm Muster', $settings->from_long); }