Set contact types (customer/vendor)

This commit is contained in:
Cüneyt Şentürk 2020-01-22 21:24:00 +03:00
parent f60b34d668
commit 46f8c44fff

View File

@ -17,4 +17,29 @@ trait Contacts
return ($return == 'array') ? explode(',', $types) : $types;
}
public function setCustomerType($new_type)
{
$this->setType($new_type, 'customer');
}
public function setVendorType($new_type)
{
$this->setType($new_type, 'vendor');
}
public function setType($new_type, $index)
{
$types = explode(',', setting('contact.type.' . $index, $index));
if (in_array($new_type, $types)) {
return;
}
$types[] = $new_type;
setting([
'contact.type.' . $index => implode(',', $types),
])->save();
}
}