diff --git a/src/Http/Controllers/ImportController.php b/src/Http/Controllers/ImportController.php index 6eebb41..70feaf7 100644 --- a/src/Http/Controllers/ImportController.php +++ b/src/Http/Controllers/ImportController.php @@ -77,7 +77,7 @@ public function store(CreateImportRequest $request) 'type' => $request->destination_type, 'collection' => Arr::first($request->destination_collection), 'taxonomy' => Arr::first($request->destination_taxonomy), - 'site' => $request->destination_site, + 'site' => Arr::first($request->destination_site), ])->filter()->all(), ]); diff --git a/src/Http/Requests/CreateImportRequest.php b/src/Http/Requests/CreateImportRequest.php index 223eba9..5f39e37 100644 --- a/src/Http/Requests/CreateImportRequest.php +++ b/src/Http/Requests/CreateImportRequest.php @@ -57,7 +57,7 @@ public function rules(): array 'destination_site' => [ Rule::requiredIf(fn () => Site::hasMultiple() && $this->destination_type === 'entries'), function (string $attribute, mixed $value, Closure $fail) { - if ($value && $this->destination_collection && ! Collection::find($this->destination_collection[0])->sites()->contains($value)) { + if (isset($value[0]) && $this->destination_collection && ! Collection::find($this->destination_collection[0])->sites()->contains($value[0])) { $fail('The chosen collection is not available on this site.')->translate(); } }, diff --git a/tests/Imports/StoreImportTest.php b/tests/Imports/StoreImportTest.php index 672d9e4..b2e2c5b 100644 --- a/tests/Imports/StoreImportTest.php +++ b/tests/Imports/StoreImportTest.php @@ -76,7 +76,7 @@ public function it_stores_a_collection_import_with_a_site() ], 'destination_type' => 'entries', 'destination_collection' => ['posts'], - 'destination_site' => 'en', + 'destination_site' => ['en'], 'strategy' => ['create', 'update'], ]) ->assertJsonStructure(['redirect']); @@ -114,7 +114,7 @@ public function it_cant_store_a_collection_import_when_the_collection_is_not_ava ], 'destination_type' => 'entries', 'destination_collection' => ['posts'], - 'destination_site' => 'fr', + 'destination_site' => ['fr'], 'strategy' => ['create', 'update'], ]) ->assertSessionHasErrors('destination_site');