-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/PPF-463
# Conflicts: # app/Domain/Integrations/Controllers/IntegrationController.php
- Loading branch information
Showing
18 changed files
with
356 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Nova\Actions; | ||
|
||
use App\Domain\Integrations\Models\IntegrationModel; | ||
use App\Domain\Integrations\Organizer; | ||
use App\Domain\Integrations\Repositories\IntegrationRepository; | ||
use App\Domain\Integrations\Repositories\OrganizerRepository; | ||
use App\Domain\Organizations\Models\OrganizationModel; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Support\Collection; | ||
use Laravel\Nova\Actions\Action; | ||
use Laravel\Nova\Actions\ActionResponse; | ||
use Laravel\Nova\Fields\ActionFields; | ||
use Laravel\Nova\Fields\Select; | ||
use Laravel\Nova\Fields\Text; | ||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
final class ActivateUitpasIntegration extends Action | ||
{ | ||
use InteractsWithQueue; | ||
use Queueable; | ||
|
||
public function __construct( | ||
private readonly IntegrationRepository $integrationRepository, | ||
private readonly OrganizerRepository $organizerRepository | ||
) { | ||
} | ||
|
||
public function handle(ActionFields $fields, Collection $integrations): ActionResponse | ||
{ | ||
/** @var IntegrationModel $integration */ | ||
$integration = $integrations->first(); | ||
|
||
/** @var string $organizationIdAsString */ | ||
$organizationIdAsString = $fields->get('organization'); | ||
$organizationId = Uuid::fromString($organizationIdAsString); | ||
|
||
/** @var string $organizers */ | ||
$organizers = $fields->get('organizers'); | ||
$organizerArray = array_map('trim', explode(',', $organizers)); | ||
|
||
foreach ($organizerArray as $organizer) { | ||
$this->organizerRepository->create( | ||
new Organizer( | ||
Uuid::uuid4(), | ||
Uuid::fromString($integration->id), | ||
$organizer | ||
) | ||
); | ||
} | ||
|
||
$this->integrationRepository->activateWithOrganization( | ||
Uuid::fromString($integration->id), | ||
$organizationId, | ||
null | ||
); | ||
|
||
return Action::message('Integration "' . $integration->name . '" activated.'); | ||
} | ||
|
||
public function fields(NovaRequest $request): array | ||
{ | ||
return [ | ||
Select::make('Organization', 'organization') | ||
->options( | ||
OrganizationModel::query()->pluck('name', 'id') | ||
) | ||
->rules( | ||
'required', | ||
'exists:organizations,id' | ||
), | ||
Text::make('Organizer(s)', 'organizers') | ||
->rules( | ||
'nullable', | ||
'string' | ||
), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.