35 lines
1.6 KiB
PHP
35 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Event\Controllers\MailCompose;
|
|
|
|
use App\Scopes\CommonController;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ByGroupController extends CommonController
|
|
{
|
|
public function __invoke(string $eventIdentifier, string $groupType, Request $request) {
|
|
$event = $this->events->getByIdentifier($eventIdentifier, true);
|
|
$recipients = [];
|
|
switch ($groupType) {
|
|
case 'by-local-group':
|
|
$participants = $this->eventParticipants->groupByLocalGroup($event, $request, $request->input('groupName'));
|
|
$recipients = $this->eventParticipants->getMailAddresses($participants[$request->input('groupName')]);
|
|
break;
|
|
case 'by-participation-group':
|
|
$participants = $this->eventParticipants->groupByParticipationType($event, $request, $request->input('groupName'));
|
|
$recipients = $this->eventParticipants->getMailAddresses($participants[$request->input('groupName')]);
|
|
break;
|
|
case 'signed-off':
|
|
$participants = $this->eventParticipants->getSignedOffParticipants($event, $request, $request->input('groupName'));
|
|
$recipients = $this->eventParticipants->getMailAddresses($participants[$request->input('groupName')]);
|
|
break;
|
|
default:
|
|
$participants = $this->eventParticipants->getForList($event, $request);
|
|
$recipients = $this->eventParticipants->getMailAddresses($participants);
|
|
|
|
}
|
|
|
|
return response()->json(['recipients' => $recipients]);
|
|
}
|
|
}
|