Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Eelen committed Aug 6, 2024
1 parent e17b052 commit df95787
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/Domain/Integrations/Controllers/IntegrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use App\Domain\Integrations\Repositories\IntegrationRepository;
use App\Domain\Integrations\Repositories\IntegrationUrlRepository;
use App\Domain\Integrations\Repositories\UdbOrganizerRepository;
use App\Domain\Integrations\UdbOrganizerCollection;
use App\Domain\Integrations\UdbOrganizers;
use App\Domain\KeyVisibilityUpgrades\KeyVisibilityUpgrade;
use App\Domain\KeyVisibilityUpgrades\Repositories\KeyVisibilityUpgradeRepository;
use App\Domain\Organizations\Repositories\OrganizationRepository;
Expand Down Expand Up @@ -304,7 +304,7 @@ public function updateOrganizers(string $integrationId, UpdateIntegrationUdbOrga
fn (UdbOrganizer $organizer) => !in_array($organizer->organizerId, $organizerIds->toArray(), true)
);

$this->organizerRepository->createInBulk(new UdbOrganizerCollection($newOrganizers));
$this->organizerRepository->createInBulk(new UdbOrganizers($newOrganizers));

return Redirect::back();
}
Expand Down Expand Up @@ -334,7 +334,7 @@ public function requestActivation(string $id, RequestActivationRequest $request)
Uuid::fromString($id),
$organization->id,
$request->input('coupon'),
new UdbOrganizerCollection(...UdbOrganizerMapper::mapActivationRequest($request, $id))
new UdbOrganizers(...UdbOrganizerMapper::mapActivationRequest($request, $id))
);

return Redirect::back();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use App\Domain\Integrations\KeyVisibility;
use App\Domain\Integrations\Models\IntegrationModel;
use App\Domain\Integrations\UdbOrganizer;
use App\Domain\Integrations\UdbOrganizerCollection;
use App\Domain\Integrations\UdbOrganizers;
use App\Pagination\PaginatedCollection;
use App\Pagination\PaginationInfo;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -103,7 +103,7 @@ public function getByContactEmail(string $email, ?string $searchQuery = null): P
);
}

public function requestActivation(UuidInterface $id, UuidInterface $organizationId, ?string $couponCode, UdbOrganizerCollection $organizers=null): void
public function requestActivation(UuidInterface $id, UuidInterface $organizationId, ?string $couponCode, UdbOrganizers $organizers=null): void
{
DB::transaction(function () use ($couponCode, $id, $organizationId, $organizers): void {
if ($organizers !== null) {
Expand All @@ -129,25 +129,28 @@ public function activate(UuidInterface $id): void
$integrationModel->activate();
}

public function activateWithOrganization(UuidInterface $integrationId, UuidInterface $organizationId, ?string $couponCode, array $organizers=[]): void
/**
* @param string[] $organizers
*/
public function activateWithOrganization(UuidInterface $id, UuidInterface $organizationId, ?string $couponCode, array $organizers=[]): void
{
DB::transaction(function () use ($couponCode, $integrationId, $organizationId, $organizers): void {
DB::transaction(function () use ($couponCode, $id, $organizationId, $organizers): void {
foreach ($organizers as $organizer) {
$this->udbOrganizerRepository->create(
new UdbOrganizer(
Uuid::uuid4(),
$integrationId,
$id,
$organizer
)
);
}

if ($couponCode) {
$this->useCouponOnIntegration($integrationId, $couponCode);
$this->useCouponOnIntegration($id, $couponCode);
}

/** @var IntegrationModel $integrationModel */
$integrationModel = IntegrationModel::query()->findOrFail($integrationId->toString());
$integrationModel = IntegrationModel::query()->findOrFail($id->toString());
$integrationModel->activateWithOrganization($organizationId);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use App\Domain\Integrations\Models\UdbOrganizerModel;
use App\Domain\Integrations\UdbOrganizer;
use App\Domain\Integrations\UdbOrganizerCollection;
use App\Domain\Integrations\UdbOrganizers;
use Illuminate\Support\Facades\DB;

final class EloquentUdbOrganizerRepository implements UdbOrganizerRepository
Expand All @@ -20,15 +20,11 @@ public function create(UdbOrganizer $organizer): void
]);
}

public function createInBulk(UdbOrganizerCollection $organizers): void
public function createInBulk(UdbOrganizers $organizers): void
{
DB::transaction(function () use ($organizers): void {
foreach ($organizers as $organizer) {
UdbOrganizerModel::query()->create([
'id' => $organizer->id->toString(),
'integration_id' => $organizer->integrationId->toString(),
'organizer_id' => $organizer->organizerId,
]);
$this->create($organizer);
}
});
}
Expand Down
10 changes: 7 additions & 3 deletions app/Domain/Integrations/Repositories/IntegrationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Domain\Integrations\Repositories;

use App\Domain\Integrations\Integration;
use App\Domain\Integrations\UdbOrganizerCollection;
use App\Domain\Integrations\UdbOrganizers;
use App\Pagination\PaginatedCollection;
use Ramsey\Uuid\UuidInterface;

Expand All @@ -18,8 +18,12 @@ public function getById(UuidInterface $id): Integration;
public function getByIdWithTrashed(UuidInterface $id): Integration;
public function deleteById(UuidInterface $id): ?bool;
public function getByContactEmail(string $email, ?string $searchQuery): PaginatedCollection;
public function requestActivation(UuidInterface $id, UuidInterface $organizationId, ?string $couponCode, UdbOrganizerCollection $organizers=null): void;
public function requestActivation(UuidInterface $id, UuidInterface $organizationId, ?string $couponCode, UdbOrganizers $organizers=null): void;
public function activate(UuidInterface $id): void;
public function activateWithOrganization(UuidInterface $integrationId, UuidInterface $organizationId, ?string $couponCode, array $organizers=[]): void;

/**
* @param string[] $organizers
*/
public function activateWithOrganization(UuidInterface $id, UuidInterface $organizationId, ?string $couponCode, array $organizers=[]): void;
public function approve(UuidInterface $id): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace App\Domain\Integrations\Repositories;

use App\Domain\Integrations\UdbOrganizer;
use App\Domain\Integrations\UdbOrganizerCollection;
use App\Domain\Integrations\UdbOrganizers;

interface UdbOrganizerRepository
{
public function create(UdbOrganizer $organizer): void;

public function createInBulk(UdbOrganizerCollection $organizers): void;
public function createInBulk(UdbOrganizers $organizers): void;

public function delete(UdbOrganizer $organizer): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
/**
* @extends Collection<int, UdbOrganizer>
*/
final class UdbOrganizerCollection extends Collection
final class UdbOrganizers extends Collection
{
}

0 comments on commit df95787

Please sign in to comment.