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;
|
|
|
|
|
2023-08-02 17:03:56 -07:00
|
|
|
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()
|
|
|
|
{
|
2023-08-02 17:03:56 -07:00
|
|
|
$this->originalSendCheckInEmailValue = $this->sendCheckInEmail;
|
|
|
|
|
2023-08-02 16:04:01 -07:00
|
|
|
if ($this->eulaText || $this->useDefaultEula) {
|
2023-08-02 18:02:56 -07:00
|
|
|
$this->sendCheckInEmail = 1;
|
2023-08-02 16:04:01 -07:00
|
|
|
}
|
2023-08-01 17:29:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.category-edit-form');
|
|
|
|
}
|
|
|
|
|
2023-08-02 16:04:01 -07:00
|
|
|
public function updated($property, $value)
|
|
|
|
{
|
2023-08-02 17:03:56 -07:00
|
|
|
if (! in_array($property, ['eulaText', 'useDefaultEula'])) {
|
|
|
|
return;
|
2023-08-02 16:04:01 -07:00
|
|
|
}
|
2023-08-02 17:03:56 -07:00
|
|
|
|
2023-08-02 18:02:56 -07:00
|
|
|
$this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? 1 : $this->originalSendCheckInEmailValue;
|
2023-08-02 16:04:01 -07:00
|
|
|
}
|
|
|
|
|
2023-08-02 11:36:20 -07:00
|
|
|
public function getShouldDisplayEmailMessageProperty(): bool
|
2023-08-01 17:29:23 -07:00
|
|
|
{
|
2023-08-02 11:36:20 -07:00
|
|
|
return $this->eulaText || $this->useDefaultEula;
|
2023-08-01 17:29:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getEmailMessageProperty(): string
|
|
|
|
{
|
2023-08-02 11:36:20 -07:00
|
|
|
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
|
|
|
}
|
2023-08-02 16:18:57 -07:00
|
|
|
|
|
|
|
public function getEulaTextDisabledProperty()
|
|
|
|
{
|
2023-08-02 18:24:32 -07:00
|
|
|
return (bool)$this->useDefaultEula;
|
2023-08-02 16:18:57 -07:00
|
|
|
}
|
2023-08-02 16:52:56 -07:00
|
|
|
|
|
|
|
public function getSendCheckInEmailDisabledProperty()
|
|
|
|
{
|
|
|
|
return $this->eulaText || $this->useDefaultEula;
|
|
|
|
}
|
2023-08-01 17:29:23 -07:00
|
|
|
}
|