diff --git a/app/Mailgateway/Actions/StoreAction.php b/app/Mailgateway/Actions/StoreAction.php new file mode 100644 index 00000000..d427ba0a --- /dev/null +++ b/app/Mailgateway/Actions/StoreAction.php @@ -0,0 +1,33 @@ + 'required|string|max:255', + 'domain' => 'required|string|max:255', + 'type.class' => ['required', 'string', 'max:255', Rule::in(app('mail-gateways'))], + 'type.params' => 'present', + ]; + } + + public function asController(ActionRequest $request): void + { + $this->handle($request->validated()); + } +} diff --git a/app/Mailgateway/Resources/MailgatewayResource.php b/app/Mailgateway/Resources/MailgatewayResource.php index 846ad1d0..d919506c 100644 --- a/app/Mailgateway/Resources/MailgatewayResource.php +++ b/app/Mailgateway/Resources/MailgatewayResource.php @@ -36,6 +36,18 @@ class MailgatewayResource extends JsonResource 'links' => [ 'store' => route('api.mailgateway.store'), ], + 'types' => app('mail-gateways')->map(fn ($gateway) => [ + 'id' => $gateway, + 'name' => $gateway::name(), + ]), + 'default' => [ + 'domain' => '', + 'name' => '', + 'type' => [ + 'params' => [], + 'class' => null, + ], + ], ]; } } diff --git a/resources/js/views/mailgateway/Index.vue b/resources/js/views/mailgateway/Index.vue index 065dcc74..8eed8e08 100644 --- a/resources/js/views/mailgateway/Index.vue +++ b/resources/js/views/mailgateway/Index.vue @@ -1,21 +1,18 @@