sls/app/Actions/Interview/ScheduleInterviewAction.php
kushal.saha e4fabef1d3 feat(interview): add icalendar invites, white date pickers, and drawer validation feedback
- integrate spatie/icalendar-generator for candidate & panelist .ics invitations (RSVP & 15m alerts)
    - add StoreInterviewRequest, ScheduleInterviewDto, and invitation/reminder queued actions
    - add migration for job_title, round, description, and reminder_sent_at on interviews table
    - style datetime-local picker indicators to pure white on dark input backgrounds
    - support button loading spinners with :showLoader="true" and loadingText
    - auto-open schedule drawer on validation failure with inline @error alerts and old() bindings
2026-08-27 10:16:46 +00:00

56 lines
2.0 KiB
PHP

<?php
namespace App\Actions\Interview;
use App\DTOs\Interview\ScheduleInterviewDto;
use App\Models\Interview;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class ScheduleInterviewAction
{
public function __construct(
protected SendInterviewInvitationsAction $sendInvitationsAction
) {}
/**
* Provision and schedule an interview assessment session, then trigger calendar invitations.
*/
public function execute(ScheduleInterviewDto $dto, ?int $creatorId = null): Interview
{
$tempPassword = 'Pass-'.rand(100000, 999999);
$cleanPhone = preg_replace('/[^0-9]/', '', $dto->candidatePhone);
$cleanName = Str::slug($dto->candidateName);
$submissionUniqueId = $cleanName.'_'.$cleanPhone.'_'.time();
$scheduledAt = $dto->scheduledAt ? Carbon::parse($dto->scheduledAt) : now();
$expiresAt = $scheduledAt->copy()->addHours($dto->validHours);
$interview = DB::transaction(function () use ($dto, $tempPassword, $submissionUniqueId, $scheduledAt, $expiresAt, $creatorId) {
return Interview::create([
'candidate_name' => $dto->candidateName,
'candidate_email' => $dto->candidateEmail,
'candidate_phone' => $dto->candidatePhone,
'job_title' => $dto->jobTitle,
'round' => $dto->round,
'description' => $dto->description,
'temp_password' => $tempPassword,
'scheduled_at' => $scheduledAt,
'expires_at' => $expiresAt,
'language' => $dto->language,
'status' => 'scheduled',
'assigned_interviewers' => $dto->assignedInterviewers,
'proctor_logs' => [],
'submission_unique_id' => $submissionUniqueId,
'created_by' => $creatorId,
]);
});
// Trigger iCalendar generation & queued emails
$this->sendInvitationsAction->execute($interview);
return $interview;
}
}