Level 1
class PopupMeetingCompany extends Component
{
public $isOpen = false;
public $key;
public $resetKey = false;
protected $listeners = ['refreshPopupMeetingCompany' => 'handleRefreshPopupMeetingCompany'];
public function handleRefreshPopupMeetingCompany($resetKey = false)
{
$this->reset();
$this->resetKey = $resetKey;
}
public function render()
{
$student = auth('web')->user()->load('conversations');
$today = now()->format('Y-m-d');
$this->key = "modal-meeting-company-{$today}-{$student->id}";
if ($this->resetKey) {
Cache::forget($this->key);
}
if (!Cache::has($this->key)) {
$this->conversations = $student->conversations()
->orderBy('id')
->get();
$this->totalMeeting = $this->conversations->count();
if ($this->totalMeeting > 0) {
$this->dispatch('showModal');
$this->currentMeeting = 0;
$this->isOpen = true;
}
}
if (isset($this->currentMeeting)){
$this->conversation = $this->conversations[$this->currentMeeting];
$this->canSubmit = $this->canSubmit();
}
return view('livewire.student.modal.popup-meeting-company');
}
public function save()
{
if ($this->currentMeeting < $this->totalMeeting) {
$note = $this->declineReasons ?: ($this->consideringReasons ?: null);
$noteOther = $this->declineReasonOther ?? $this->consideringReasonOther ?? null;
try {
DB::beginTransaction();
}
DB::commit();
} catch (Exception $e) {
DB::rollBack();
}
$this->currentMeeting++;
if ($this->currentMeeting >= $this->totalMeeting) {
$this->dispatch('updateDisabledPopupMeetingCompany');
$this->currentMeeting = null;
$this->isShowContentPopup = false;
}
}
$this->status = null;
$this->updatedStatus();
}