snipe-it/app/Livewire/CategoryEditForm.php

68 lines
1.5 KiB
PHP
Raw Normal View History

2023-08-01 17:29:23 -07:00
<?php
2024-05-29 12:07:48 -07:00
namespace App\Livewire;
2023-08-01 17:29:23 -07:00
use Livewire\Component;
class CategoryEditForm extends Component
{
public $defaultEulaText;
public $eulaText;
public $originalSendCheckInEmailValue;
2023-08-02 12:58:07 -07:00
public $requireAcceptance;
2023-08-01 17:29:23 -07:00
2023-08-02 16:06:59 -07:00
public $sendCheckInEmail;
2023-08-02 18:24:32 -07:00
2023-08-02 12:58:07 -07:00
public $useDefaultEula;
2023-08-01 17:29:23 -07:00
public function mount()
{
$this->originalSendCheckInEmailValue = $this->sendCheckInEmail;
if ($this->eulaText || $this->useDefaultEula) {
$this->sendCheckInEmail = 1;
}
2023-08-01 17:29:23 -07:00
}
public function render()
{
return view('livewire.category-edit-form');
}
public function updated($property, $value)
{
if (! in_array($property, ['eulaText', 'useDefaultEula'])) {
return;
}
$this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? 1 : $this->originalSendCheckInEmailValue;
}
public function getShouldDisplayEmailMessageProperty(): bool
2023-08-01 17:29:23 -07:00
{
return $this->eulaText || $this->useDefaultEula;
2023-08-01 17:29:23 -07:00
}
public function getEmailMessageProperty(): string
{
if ($this->useDefaultEula) {
return trans('admin/categories/general.email_will_be_sent_due_to_global_eula');
}
return trans('admin/categories/general.email_will_be_sent_due_to_category_eula');
2023-08-01 17:29:23 -07:00
}
public function getEulaTextDisabledProperty()
{
2023-08-02 18:24:32 -07:00
return (bool)$this->useDefaultEula;
}
public function getSendCheckInEmailDisabledProperty()
{
return $this->eulaText || $this->useDefaultEula;
}
2023-08-01 17:29:23 -07:00
}