diff --git a/app/Maildispatcher/Models/Maildispatcher.php b/app/Maildispatcher/Models/Maildispatcher.php index 3cdf717f..c17e0176 100644 --- a/app/Maildispatcher/Models/Maildispatcher.php +++ b/app/Maildispatcher/Models/Maildispatcher.php @@ -2,7 +2,7 @@ namespace App\Maildispatcher\Models; -use App\Mailgateway\Models\Mailgateway; +use Modules\Mailgateway\Models\Mailgateway; use Database\Factories\Maildispatcher\Models\MaildispatcherFactory; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; diff --git a/app/Maildispatcher/Resources/MaildispatcherResource.php b/app/Maildispatcher/Resources/MaildispatcherResource.php index 7250d916..9928209e 100644 --- a/app/Maildispatcher/Resources/MaildispatcherResource.php +++ b/app/Maildispatcher/Resources/MaildispatcherResource.php @@ -4,7 +4,7 @@ namespace App\Maildispatcher\Resources; use App\Lib\HasMeta; use App\Maildispatcher\Models\Maildispatcher; -use App\Mailgateway\Models\Mailgateway; +use Modules\Mailgateway\Models\Mailgateway; use App\Mailgateway\Resources\MailgatewayResource; use App\Member\FilterScope; use App\Member\Member; diff --git a/app/Mailgateway/Actions/StoreAction.php b/app/Mailgateway/Actions/StoreAction.php deleted file mode 100644 index 41194c6a..00000000 --- a/app/Mailgateway/Actions/StoreAction.php +++ /dev/null @@ -1,27 +0,0 @@ - $input - */ - public function handle(array $input): void - { - $this->checkIfWorks($input); - Mailgateway::create($input); - } - - public function asController(ActionRequest $request): void - { - $this->handle($request->validated()); - } -} diff --git a/app/Mailgateway/Actions/UpdateAction.php b/app/Mailgateway/Actions/UpdateAction.php deleted file mode 100644 index 4b794520..00000000 --- a/app/Mailgateway/Actions/UpdateAction.php +++ /dev/null @@ -1,28 +0,0 @@ - $input - */ - public function handle(Mailgateway $mailgateway, array $input): void - { - $this->checkIfWorks($input); - - $mailgateway->update($input); - } - - public function asController(Mailgateway $mailgateway, ActionRequest $request): void - { - $this->handle($mailgateway, $request->validated()); - } -} diff --git a/app/Mailgateway/Actions/ValidatesRequests.php b/app/Mailgateway/Actions/ValidatesRequests.php deleted file mode 100644 index 50df8bf0..00000000 --- a/app/Mailgateway/Actions/ValidatesRequests.php +++ /dev/null @@ -1,65 +0,0 @@ - $input - */ - public function checkIfWorks(array $input): void - { - if (!app(data_get($input, 'type.cls'))->setParams($input['type']['params'])->works()) { - throw ValidationException::withMessages(['connection' => 'Verbindung fehlgeschlagen.']); - } - } - - /** - * @return array - */ - public function rules(): array - { - return [ - 'name' => 'required|string|max:255', - 'domain' => 'required|string|max:255', - ...$this->typeValidation(), - 'type.params' => 'present|array', - ...collect(request()->input('type.cls')::rules('storeValidator'))->mapWithKeys(fn ($rules, $key) => ["type.params.{$key}" => $rules]), - ]; - } - - /** - * @return array - */ - public function getValidationAttributes(): array - { - return [ - 'type.cls' => 'Typ', - 'name' => 'Beschreibung', - 'domain' => 'Domain', - ...collect(request()->input('type.cls')::fieldNames())->mapWithKeys(fn ($attribute, $key) => ["type.params.{$key}" => $attribute]), - ]; - } - - /** - * @return array - */ - private function typeValidation(): array - { - return [ - 'type.cls' => ['required', 'string', 'max:255', Rule::in(app('mail-gateways'))], - ]; - } - - public function prepareForValidation(ActionRequest $request): void - { - if (!is_subclass_of(request()->input('type.cls'), Type::class)) { - throw ValidationException::withMessages(['type.cls' => 'Typ ist nicht valide.']); - } - } -} diff --git a/app/Mailgateway/MailgatewaySettings.php b/app/Mailgateway/MailgatewaySettings.php index 5a84f267..31c38d57 100644 --- a/app/Mailgateway/MailgatewaySettings.php +++ b/app/Mailgateway/MailgatewaySettings.php @@ -2,7 +2,7 @@ namespace App\Mailgateway; -use App\Mailgateway\Models\Mailgateway; +use Modules\Mailgateway\Models\Mailgateway; use App\Mailgateway\Resources\MailgatewayResource; use App\Setting\LocalSettings; diff --git a/app/Mailgateway/Resources/MailgatewayResource.php b/app/Mailgateway/Resources/MailgatewayResource.php index d27a838f..3386d35a 100644 --- a/app/Mailgateway/Resources/MailgatewayResource.php +++ b/app/Mailgateway/Resources/MailgatewayResource.php @@ -3,7 +3,7 @@ namespace App\Mailgateway\Resources; use App\Lib\HasMeta; -use App\Mailgateway\Models\Mailgateway; +use Modules\Mailgateway\Models\Mailgateway; use Illuminate\Http\Resources\Json\JsonResource; /** diff --git a/modules/Mailgateway/Components/Form.php b/modules/Mailgateway/Components/Form.php index b9adde5f..ce1f4390 100644 --- a/modules/Mailgateway/Components/Form.php +++ b/modules/Mailgateway/Components/Form.php @@ -2,7 +2,7 @@ namespace Modules\Mailgateway\Components; -use App\Mailgateway\Models\Mailgateway; +use Modules\Mailgateway\Models\Mailgateway; use App\Mailgateway\Types\Type; use Illuminate\Support\Collection; use Illuminate\Validation\ValidationException; diff --git a/modules/Mailgateway/Components/SettingView.php b/modules/Mailgateway/Components/SettingView.php index b6d892ea..977383ba 100644 --- a/modules/Mailgateway/Components/SettingView.php +++ b/modules/Mailgateway/Components/SettingView.php @@ -2,7 +2,7 @@ namespace Modules\Mailgateway\Components; -use App\Mailgateway\Models\Mailgateway; +use Modules\Mailgateway\Models\Mailgateway; use Livewire\Component; use Modules\Mailgateway\MailgatewaySettings; diff --git a/modules/Mailgateway/IndexTest.php b/modules/Mailgateway/IndexTest.php index d806616a..b0e018e7 100644 --- a/modules/Mailgateway/IndexTest.php +++ b/modules/Mailgateway/IndexTest.php @@ -1,8 +1,8 @@ */ use HasFactory; use HasUuids; diff --git a/database/factories/Mailgateway/Models/MailgatewayFactory.php b/modules/Mailgateway/Models/MailgatewayFactory.php similarity index 82% rename from database/factories/Mailgateway/Models/MailgatewayFactory.php rename to modules/Mailgateway/Models/MailgatewayFactory.php index 968599a4..3f97c29c 100644 --- a/database/factories/Mailgateway/Models/MailgatewayFactory.php +++ b/modules/Mailgateway/Models/MailgatewayFactory.php @@ -1,14 +1,13 @@ + * @extends Factory */ class MailgatewayFactory extends Factory { diff --git a/modules/Mailgateway/StoreTest.php b/modules/Mailgateway/StoreTest.php index 69c8445b..debb6dfb 100644 --- a/modules/Mailgateway/StoreTest.php +++ b/modules/Mailgateway/StoreTest.php @@ -1,6 +1,6 @@