model_id = $model_id; $this->fieldset_id = $this->model?->fieldset_id; $this->add_default_values = ($this->model?->defaultValues->count() > 0); $this->fields->each(function ($field) { if ($field->element === 'checkbox') { $this->selectedValues[$field->db_column] = explode(', ', $field->defaultValue($this->model_id)); } else { $this->selectedValues[$field->db_column] = $field->defaultValue($this->model_id); } }); } #[Computed] public function model() { return AssetModel::find($this->model_id); } #[Computed] public function fields() { $customFieldset = CustomFieldset::find($this->fieldset_id); if ($customFieldset) { return $customFieldset?->fields; } return collect(); } public function render() { return view('livewire.custom-field-set-default-values-for-model'); } }