check if model has category/contact property #2568

This commit is contained in:
Denis Duliçi 2022-08-02 23:39:40 +03:00
parent 2a1d61ff84
commit 1dd103d155
2 changed files with 7 additions and 5 deletions

View File

@ -33,7 +33,7 @@ class Category extends Form
$model = $this->getParentData('model');
if (! empty($model)) {
if (! empty($model) && ! empty($model->category_id)) {
$this->selected = $model->category_id;
$selected_category = $model->category;

View File

@ -39,12 +39,14 @@ class Contact extends Form
$model = $this->getParentData('model');
if (! empty($model)) {
if (! empty($model) && ! empty($model->contact_id)) {
$this->selected = $model->contact_id;
if (! $this->contacts->has($model->contact_id) && ($contact = $model->contact)) {
$this->contacts->put($contact->id, $contact->name);
$selected_contact = $model->contact;
}
if (! empty($selected_contact) && ! $this->contacts->has($selected_contact->id)) {
$this->contacts->put($selected_contact->id, $selected_contact->name);
}
return view($this->view);