<?php

namespace App\Observers;

use App\Notifications\HrActionNotification;
use Modules\Employee\Models\Employee;
use Modules\Recruit\Models\InterviewSchedule;


class InterviewScheduleObserver
{
    /**
     * Handle the InterviewSchedule "created" event.
     */
    public function created(InterviewSchedule $interviewSchedule): void
    {
        $interviewers = Employee::whereIn('id', $interviewSchedule->interviewer_choices)->get();
        $interviewers->each->notify(new HrActionNotification('interviewer', $interviewSchedule,'you have been selected as interviewer'));
        $interviewSchedule->jobPost->jobApplications->each->notify(new HrActionNotification('interviewee', $interviewSchedule,'you interview has been scheduled'));
    }

    /**
     * Handle the InterviewSchedule "updated" event.
     */
    public function updated(InterviewSchedule $interviewSchedule): void
    {
        //
    }

    /**
     * Handle the InterviewSchedule "deleted" event.
     */
    public function deleted(InterviewSchedule $interviewSchedule): void
    {
        //
    }

    /**
     * Handle the InterviewSchedule "restored" event.
     */
    public function restored(InterviewSchedule $interviewSchedule): void
    {
        //
    }

    /**
     * Handle the InterviewSchedule "force deleted" event.
     */
    public function forceDeleted(InterviewSchedule $interviewSchedule): void
    {
        //
    }
}