Set contact types (customer/vendor)
This commit is contained in:
		@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user