Basic implementation of payment methods
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ class RemovePaymentMethodUsageAction
|
|||||||
public function execute(AvailablePaymentMethod $availablePaymentMethod): void
|
public function execute(AvailablePaymentMethod $availablePaymentMethod): void
|
||||||
{
|
{
|
||||||
foreach ($availablePaymentMethod->events()->get() as $event) {
|
foreach ($availablePaymentMethod->events()->get() as $event) {
|
||||||
$event->paymentMethods()->detach($availablePaymentMethod->id);
|
$event->paymentMethods()->detach($availablePaymentMethod->slug);
|
||||||
|
|
||||||
$remainingActive = $event->paymentMethods()->where('active', true)->count();
|
$remainingActive = $event->paymentMethods()->where('active', true)->count();
|
||||||
if ($remainingActive === 0 && $event->registration_allowed) {
|
if ($remainingActive === 0 && $event->registration_allowed) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class CreateEventCommand {
|
|||||||
foreach (AvailablePaymentMethod::where('active', true)->get() as $availablePaymentMethod) {
|
foreach (AvailablePaymentMethod::where('active', true)->get() as $availablePaymentMethod) {
|
||||||
EventPaymentMethods::create([
|
EventPaymentMethods::create([
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'available_payment_method_id' => $availablePaymentMethod->id,
|
'slug' => $availablePaymentMethod->slug,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class SignUpCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$participantAge = new Age($this->request->birthday);
|
$participantAge = new Age($this->request->birthday);
|
||||||
$paymentMethod = $this->request->event->paymentMethods()->where('active', true)->first();
|
|
||||||
|
|
||||||
$response->participant = $this->request->event->participants()->create(
|
$response->participant = $this->request->event->participants()->create(
|
||||||
[
|
[
|
||||||
@@ -62,7 +61,7 @@ class SignUpCommand {
|
|||||||
'notes' => $this->request->notes,
|
'notes' => $this->request->notes,
|
||||||
'amount' => $this->request->amount,
|
'amount' => $this->request->amount,
|
||||||
'payment_purpose' => $this->request->event->name . ' - Beitrag ' . $this->request->firstname . ' ' . $this->request->lastname,
|
'payment_purpose' => $this->request->event->name . ' - Beitrag ' . $this->request->firstname . ' ' . $this->request->lastname,
|
||||||
'payment_method' => $paymentMethod?->slug, // available_payment_methods.slug === payment_methods.slug
|
'payment_method' => $this->request->paymentMethod,
|
||||||
'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
|
'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class SignUpRequest {
|
|||||||
public int $arrival_eating,
|
public int $arrival_eating,
|
||||||
public int $departure_eating,
|
public int $departure_eating,
|
||||||
public ?string $notes,
|
public ?string $notes,
|
||||||
public Amount $amount
|
public Amount $amount,
|
||||||
|
public ?string $paymentMethod,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ class SignupController extends CommonController {
|
|||||||
$availableEvents[] = $event->toResource()->toArray($request);
|
$availableEvents[] = $event->toResource()->toArray($request);
|
||||||
};
|
};
|
||||||
|
|
||||||
$event = $this->events->getByIdentifier($eventId, false)?->toResource()->toArray($request);
|
$eventModel = $this->events->getByIdentifier($eventId, false);
|
||||||
|
$event = $eventModel?->toResource()->toArray($request);
|
||||||
|
// Aktuell ist genau eine aktive Zahlungsmethode je Event vorgesehen; wird bereits beim Start
|
||||||
|
// der Anmeldung ermittelt und ans Frontend durchgereicht, statt erst bei der Erstellung des
|
||||||
|
// Teilnehmenden (siehe SignUpCommand).
|
||||||
|
$paymentMethod = $eventModel?->paymentMethods()->where('active', true)->first();
|
||||||
|
|
||||||
$participantData = [
|
$participantData = [
|
||||||
'firstname' => '',
|
'firstname' => '',
|
||||||
@@ -62,6 +67,7 @@ class SignupController extends CommonController {
|
|||||||
'availableEvents' => $availableEvents,
|
'availableEvents' => $availableEvents,
|
||||||
'localGroups' => $event['contributingLocalGroups'],
|
'localGroups' => $event['contributingLocalGroups'],
|
||||||
'participantData' => $participantData,
|
'participantData' => $participantData,
|
||||||
|
'paymentMethod' => $paymentMethod?->slug,
|
||||||
]);
|
]);
|
||||||
return $inertiaProvider->render();
|
return $inertiaProvider->render();
|
||||||
}
|
}
|
||||||
@@ -136,7 +142,8 @@ class SignupController extends CommonController {
|
|||||||
$registrationData['anreise_essen'],
|
$registrationData['anreise_essen'],
|
||||||
$registrationData['abreise_essen'],
|
$registrationData['abreise_essen'],
|
||||||
$registrationData['anmerkungen'],
|
$registrationData['anmerkungen'],
|
||||||
$amount
|
$amount,
|
||||||
|
$registrationData['paymentMethod'] ?? null,
|
||||||
);
|
);
|
||||||
|
|
||||||
$signupCommand = new SignUpCommand($signupRequest);
|
$signupCommand = new SignUpCommand($signupRequest);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
contributingLocalGroups.value = props.event.contributingLocalGroups?.map(t => t.id) ?? []
|
contributingLocalGroups.value = props.event.contributingLocalGroups?.map(t => t.id) ?? []
|
||||||
eatingHabits.value = props.event.eatingHabits?.map(t => t.id) ?? []
|
eatingHabits.value = props.event.eatingHabits?.map(t => t.id) ?? []
|
||||||
paymentMethods.value = props.event.paymentMethods?.map(t => t.id) ?? []
|
paymentMethods.value = props.event.paymentMethods?.map(t => t.slug) ?? []
|
||||||
});
|
});
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
|
|
||||||
<tr v-for="paymentMethod in dynmicProps.paymentMethods">
|
<tr v-for="paymentMethod in dynmicProps.paymentMethods">
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" :id="'paymentmethod' + paymentMethod.id" :value="paymentMethod.id" v-model="paymentMethods" />
|
<input type="checkbox" :id="'paymentmethod' + paymentMethod.id" :value="paymentMethod.slug" v-model="paymentMethods" />
|
||||||
<label style="padding-left: 5px;" :for="'paymentmethod' + paymentMethod.id">{{paymentMethod.name}}</label>
|
<label style="padding-left: 5px;" :for="'paymentmethod' + paymentMethod.id">{{paymentMethod.name}}</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const props = defineProps({
|
|||||||
event: Object,
|
event: Object,
|
||||||
participantData: Object,
|
participantData: Object,
|
||||||
localGroups: Array,
|
localGroups: Array,
|
||||||
|
paymentMethod: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['registrationDone'])
|
const emit = defineEmits(['registrationDone'])
|
||||||
@@ -23,7 +24,7 @@ const emit = defineEmits(['registrationDone'])
|
|||||||
const {
|
const {
|
||||||
currentStep, goToStep, formData, selectedAddons,
|
currentStep, goToStep, formData, selectedAddons,
|
||||||
submit, submitting, submitResult, summaryLoading, summaryAmount
|
submit, submitting, submitResult, summaryLoading, summaryAmount
|
||||||
} = useSignupForm(props.event, props.participantData)
|
} = useSignupForm(props.event, props.participantData, props.paymentMethod)
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
{ step: 1, label: 'Alter' },
|
{ step: 1, label: 'Alter' },
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ref, reactive, computed } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
export function useSignupForm(event, participantData) {
|
export function useSignupForm(event, participantData, paymentMethod) {
|
||||||
const currentStep = ref(1)
|
const currentStep = ref(1)
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const summaryLoading = ref(false)
|
const summaryLoading = ref(false)
|
||||||
@@ -11,6 +11,7 @@ export function useSignupForm(event, participantData) {
|
|||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
eatingHabit: 'EATING_HABIT_VEGAN',
|
eatingHabit: 'EATING_HABIT_VEGAN',
|
||||||
|
paymentMethod: paymentMethod ?? null,
|
||||||
userId: participantData.id,
|
userId: participantData.id,
|
||||||
eventId: event.id,
|
eventId: event.id,
|
||||||
vorname: participantData.firstname ?? '',
|
vorname: participantData.firstname ?? '',
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const props = defineProps({
|
|||||||
availableEvents: Array,
|
availableEvents: Array,
|
||||||
participantData: Object,
|
participantData: Object,
|
||||||
localGroups: Array,
|
localGroups: Array,
|
||||||
|
paymentMethod: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
const showSignup = ref(true)
|
const showSignup = ref(true)
|
||||||
@@ -103,6 +104,7 @@ function close() {
|
|||||||
:event="props.event"
|
:event="props.event"
|
||||||
:participantData="props.participantData ?? {}"
|
:participantData="props.participantData ?? {}"
|
||||||
:localGroups="props.localGroups ?? []"
|
:localGroups="props.localGroups ?? []"
|
||||||
|
:paymentMethod="props.paymentMethod ?? null"
|
||||||
/>
|
/>
|
||||||
<p v-else class="signup-closed-notice">
|
<p v-else class="signup-closed-notice">
|
||||||
Die Anmeldung für diese Veranstaltung ist geschlossen.
|
Die Anmeldung für diese Veranstaltung ist geschlossen.
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ class AvailablePaymentMethod extends InstancedModel
|
|||||||
|
|
||||||
public function events(): BelongsToMany
|
public function events(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Event::class, 'event_payment_methods')->withTimestamps();
|
// Pivot verknüpft über den Slug -- Event::paymentMethods() greift daher automatisch nur
|
||||||
|
// auf Events des aktuell gebundenen Tenants zu (SiteScope auf Event + AvailablePaymentMethod).
|
||||||
|
return $this->belongsToMany(Event::class, 'event_payment_methods', 'slug', 'event_id', 'slug', 'id')->withTimestamps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,10 @@ class Event extends InstancedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function paymentMethods() : BelongsToMany {
|
public function paymentMethods() : BelongsToMany {
|
||||||
return $this->belongsToMany(AvailablePaymentMethod::class, 'event_payment_methods', 'event_id', 'available_payment_method_id')->withTimestamps();
|
// Pivot verknüpft über den Slug (payment_methods.slug), nicht über die numerische id
|
||||||
|
// von available_payment_methods -- die tenant-spezifische Instanz wird dadurch implizit
|
||||||
|
// über den globalen SiteScope von AvailablePaymentMethod (gefiltert auf app('tenant')) aufgelöst.
|
||||||
|
return $this->belongsToMany(AvailablePaymentMethod::class, 'event_payment_methods', 'event_id', 'slug', 'id', 'slug')->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resetContributingLocalGroups() {
|
public function resetContributingLocalGroups() {
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ use App\Scopes\CommonModel;
|
|||||||
class EventPaymentMethods extends CommonModel
|
class EventPaymentMethods extends CommonModel
|
||||||
{
|
{
|
||||||
protected $table = 'event_payment_methods';
|
protected $table = 'event_payment_methods';
|
||||||
protected $fillable = ['event_id', 'available_payment_method_id'];
|
protected $fillable = ['event_id', 'slug'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ return new class extends Migration {
|
|||||||
Schema::create('event_payment_methods', function (Blueprint $table) {
|
Schema::create('event_payment_methods', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('event_id')->constrained('events', 'id')->restrictOnDelete()->cascadeOnUpdate();
|
$table->foreignId('event_id')->constrained('events', 'id')->restrictOnDelete()->cascadeOnUpdate();
|
||||||
$table->foreignId('available_payment_method_id')->constrained('available_payment_methods', 'id')->restrictOnDelete()->cascadeOnUpdate();
|
$table->string('slug');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('slug')->references('slug')->on('payment_methods')->restrictOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->unique(['event_id', 'slug']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user