И у меня есть компонент Livewire, как показано ниже
Код: Выделить всё
Active:
Active
Код: Выделить всё
class Advices extends Component
{
public $advices, $text, $priority, $attached_day, $active, $advice_id;
public $updateMode = false;
public function render()
{
$this->advices = Advice::all();
return view('livewire.advices');
}
private function resetInputFields(){
$this->text='';
$this->priority='';
$this->attached_day='';
$this->active='';
}
public function store()
{
$validator=$this->validate([
'text'=>'bail|required',
'priority'=>'nullable|integer',
'attached_day'=>'nullable|integer|max:99',
'active'=>'boolean'
]);
$advice= new Advice();
$advice->text= $this->text;
$advice->priority= $this->priority ?? 1;
$advice->attached_day = $this->attached_day ?? null;
$advice->active= $this->active ?? true;
$advice->timestamps = false;
$advice->save();
session()->flash('message','Advice Created Successfully.');
$this->resetInputFields();
}
}
Я имел в виду что если флажок установлен, то «активный» = true, если флажок не установлен, то «активный» = false.
Я не хочу использовать JS, поэтому, если вы можете дать мне решение без JS, я буду очень рад.
Подробнее здесь: https://stackoverflow.com/questions/791 ... ked-or-not
Мобильная версия