Move setting to bill subroute
This commit is contained in:
parent
8a30a71964
commit
dd07a68762
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Setting;
|
namespace App\Bill;
|
||||||
|
|
||||||
|
use App\Setting\BillSettings;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
@ -16,14 +17,14 @@ class SettingIndexAction
|
||||||
public function handle(BillSettings $settings): array
|
public function handle(BillSettings $settings): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'bill_from_long' => $settings->from_long,
|
'from_long' => $settings->from_long,
|
||||||
'bill_from' => $settings->from,
|
'from' => $settings->from,
|
||||||
'bill_mobile' => $settings->mobile,
|
'mobile' => $settings->mobile,
|
||||||
'bill_email' => $settings->email,
|
'email' => $settings->email,
|
||||||
'bill_website' => $settings->website,
|
'website' => $settings->website,
|
||||||
'bill_address' => $settings->address,
|
'address' => $settings->address,
|
||||||
'bill_place' => $settings->place,
|
'place' => $settings->place,
|
||||||
'bill_zip' => $settings->zip,
|
'zip' => $settings->zip,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Bill;
|
||||||
|
|
||||||
|
use App\Setting\BillSettings;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
class SettingSaveAction
|
||||||
|
{
|
||||||
|
use AsAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $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');
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Setting;
|
|
||||||
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class SettingSaveAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public function handle(array $input): void
|
|
||||||
{
|
|
||||||
$settings = app(BillSettings::class);
|
|
||||||
|
|
||||||
$settings->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');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Bill\SettingIndexAction as BillSettingIndexAction;
|
||||||
|
use App\Bill\SettingSaveAction as BillSettingSaveAction;
|
||||||
use App\Contribution\ContributionController;
|
use App\Contribution\ContributionController;
|
||||||
use App\Course\Controllers\CourseController;
|
use App\Course\Controllers\CourseController;
|
||||||
use App\Http\Controllers\HomeController;
|
use App\Http\Controllers\HomeController;
|
||||||
|
@ -15,8 +17,6 @@ use App\Payment\SendpaymentController;
|
||||||
use App\Payment\SubscriptionController;
|
use App\Payment\SubscriptionController;
|
||||||
use App\Pdf\MemberEfzController;
|
use App\Pdf\MemberEfzController;
|
||||||
use App\Pdf\MemberPdfController;
|
use App\Pdf\MemberPdfController;
|
||||||
use App\Setting\SettingIndexAction;
|
|
||||||
use App\Setting\SettingSaveAction;
|
|
||||||
|
|
||||||
Route::group(['namespace' => 'App\\Http\\Controllers'], function (): void {
|
Route::group(['namespace' => 'App\\Http\\Controllers'], function (): void {
|
||||||
Auth::routes(['register' => false]);
|
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', [SendpaymentController::class, 'create'])->name('sendpayment.create');
|
||||||
Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf');
|
Route::get('/sendpayment/pdf', [SendpaymentController::class, 'send'])->name('sendpayment.pdf');
|
||||||
Route::apiResource('member.membership', MembershipController::class);
|
Route::apiResource('member.membership', MembershipController::class);
|
||||||
Route::get('setting', SettingIndexAction::class);
|
Route::get('setting/bill', BillSettingIndexAction::class);
|
||||||
Route::post('setting', SettingSaveAction::class);
|
Route::post('setting/bill', BillSettingSaveAction::class);
|
||||||
Route::resource('member.course', CourseController::class);
|
Route::resource('member.course', CourseController::class);
|
||||||
Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz');
|
Route::get('/member/{member}/efz', MemberEfzController::class)->name('efz');
|
||||||
Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync');
|
Route::get('/member/{member}/resync', MemberResyncController::class)->name('member.resync');
|
||||||
|
|
|
@ -24,18 +24,18 @@ class SettingTest extends TestCase
|
||||||
'zip' => '12345',
|
'zip' => '12345',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->get('/setting');
|
$response = $this->get('/setting/bill');
|
||||||
|
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
$this->assertInertiaHas([
|
$this->assertInertiaHas([
|
||||||
'bill_from_long' => 'DPSG Stamm Muster',
|
'from_long' => 'DPSG Stamm Muster',
|
||||||
'bill_from' => 'Stamm Muster',
|
'from' => 'Stamm Muster',
|
||||||
'bill_mobile' => '+49 176 55555',
|
'mobile' => '+49 176 55555',
|
||||||
'bill_email' => 'max@muster.de',
|
'email' => 'max@muster.de',
|
||||||
'bill_website' => 'https://example.com',
|
'website' => 'https://example.com',
|
||||||
'bill_address' => 'Musterstr 4',
|
'address' => 'Musterstr 4',
|
||||||
'bill_place' => 'Solingen',
|
'place' => 'Solingen',
|
||||||
'bill_zip' => '12345',
|
'zip' => '12345',
|
||||||
], $response, 'data');
|
], $response, 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,18 +43,18 @@ class SettingTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
|
|
||||||
$response = $this->from('/setting')->post('/setting', [
|
$response = $this->from('/setting/bill')->post('/setting/bill', [
|
||||||
'bill_from_long' => 'DPSG Stamm Muster',
|
'from_long' => 'DPSG Stamm Muster',
|
||||||
'bill_from' => 'Stamm Muster',
|
'from' => 'Stamm Muster',
|
||||||
'bill_mobile' => '+49 176 55555',
|
'mobile' => '+49 176 55555',
|
||||||
'bill_email' => 'max@muster.de',
|
'email' => 'max@muster.de',
|
||||||
'bill_website' => 'https://example.com',
|
'website' => 'https://example.com',
|
||||||
'bill_address' => 'Musterstr 4',
|
'address' => 'Musterstr 4',
|
||||||
'bill_place' => 'Solingen',
|
'place' => 'Solingen',
|
||||||
'bill_zip' => '12345',
|
'zip' => '12345',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertRedirect('/setting');
|
$response->assertRedirect('/setting/bill');
|
||||||
$settings = app(BillSettings::class);
|
$settings = app(BillSettings::class);
|
||||||
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue