Skip to content

Commit

Permalink
Implement DB logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Jun 27, 2024
1 parent 327a8a8 commit 8c330f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
22 changes: 5 additions & 17 deletions app/Domain/Integrations/Controllers/IntegrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
use App\Domain\Integrations\IntegrationUrl;
use App\Domain\Integrations\KeyVisibility;
use App\Domain\Integrations\Mappers\OrganizationMapper;
use App\Domain\Integrations\Mappers\OrganizerMapper;
use App\Domain\Integrations\Mappers\StoreContactMapper;
use App\Domain\Integrations\Mappers\StoreIntegrationMapper;
use App\Domain\Integrations\Mappers\StoreIntegrationUrlMapper;
use App\Domain\Integrations\Mappers\KeyVisibilityUpgradeMapper;
use App\Domain\Integrations\Mappers\UpdateContactInfoMapper;
use App\Domain\Integrations\Mappers\UpdateIntegrationMapper;
use App\Domain\Integrations\Mappers\UpdateIntegrationUrlsMapper;
use App\Domain\Integrations\Organizer;
use App\Domain\Integrations\Repositories\IntegrationRepository;
use App\Domain\Integrations\Repositories\IntegrationUrlRepository;
use App\Domain\Integrations\Repositories\OrganizerRepository;
Expand Down Expand Up @@ -290,24 +290,12 @@ public function requestActivation(string $id, RequestActivationRequest $request)
}

$organization = OrganizationMapper::mapActivationRequest($request);
$organizers = $request->input('organizers') ?? [];

DB::transaction(function () use ($organizers, $id, $organization, $request): void {
$this->organizationRepository->save($organization);

foreach ($organizers as $organizer) {
$organizer = new Organizer(
Uuid::uuid4(),
Uuid::fromString($id),
Uuid::fromString($organizer['id'])
);
$this->organizerRepository->create($organizer);
}

$this->integrationRepository->requestActivation(Uuid::fromString($id), $organization->id, $request->input('coupon'));
$this->organizationRepository->save($organization);

});
$organizers = OrganizerMapper::map($request, $id);

Check failure on line 295 in app/Domain/Integrations/Controllers/IntegrationController.php

View workflow job for this annotation

GitHub Actions / Run static analysis

Parameter #1 $request of static method App\Domain\Integrations\Mappers\OrganizerMapper::map() expects App\Domain\Integrations\FormRequests\GetOrganizersRequest, App\Domain\Integrations\FormRequests\RequestActivationRequest given.
$this->organizerRepository->save(...$organizers);

Check failure on line 296 in app/Domain/Integrations/Controllers/IntegrationController.php

View workflow job for this annotation

GitHub Actions / Run static analysis

Call to an undefined method App\Domain\Integrations\Repositories\OrganizerRepository::save().

$this->integrationRepository->requestActivation(Uuid::fromString($id), $organization->id, $request->input('coupon'));

return Redirect::back();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@

use App\Domain\Integrations\Models\OrganizerModel;
use App\Domain\Integrations\Organizer;
use Illuminate\Support\Facades\DB;

final class EloquentOrganizerRepository implements OrganizerRepository
{
public function create(Organizer $organizer): void
public function create(Organizer ...$organizers): void
{
OrganizerModel::query()->create([
'id' => $organizer->id->toString(),
'integration_id' => $organizer->integrationId->toString(),
'organizer_id' => $organizer->organizerId->toString(),
]);
DB::transaction(function () use ($organizers): void {
foreach ($organizers as $organizer) {
OrganizerModel::query()->create([
'id' => $organizer->id->toString(),
'integration_id' => $organizer->integrationId->toString(),
'organizer_id' => $organizer->organizerId->toString(),
]);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

interface OrganizerRepository
{
public function create(Organizer $organizer): void;
public function create(Organizer ...$organizer): void;
}

0 comments on commit 8c330f6

Please sign in to comment.