| 1: | <?php |
| 2: | |
| 3: | namespace Aurora\Modules\Contacts\Models; |
| 4: | |
| 5: | use Aurora\System\Classes\Model; |
| 6: | use Aurora\Modules\Core\Models\User; |
| 7: | |
| 8: | class Group extends Model |
| 9: | { |
| 10: | protected $table = 'contacts_groups'; |
| 11: | protected $foreignModel = User::class; |
| 12: | protected $foreignModelIdColumn = 'IdUser'; |
| 13: | |
| 14: | public $Events = array(); |
| 15: | |
| 16: | public $GroupContacts = array(); |
| 17: | |
| 18: | protected $fillable = [ |
| 19: | 'Id', |
| 20: | 'IdUser', |
| 21: | 'UUID', |
| 22: | 'Name', |
| 23: | 'IsOrganization', |
| 24: | 'Email', |
| 25: | 'Company', |
| 26: | 'Street', |
| 27: | 'City', |
| 28: | 'State', |
| 29: | 'Zip', |
| 30: | 'Country', |
| 31: | 'Phone', |
| 32: | 'Fax', |
| 33: | 'Web', |
| 34: | 'Events' |
| 35: | ]; |
| 36: | |
| 37: | protected $casts = [ |
| 38: | 'Properties' => 'array', |
| 39: | |
| 40: | 'IsOrganization' => 'boolean' |
| 41: | ]; |
| 42: | |
| 43: | public function populate($aGroup) |
| 44: | { |
| 45: | parent::populate($aGroup); |
| 46: | |
| 47: | if (!empty($aGroup['UUID'])) { |
| 48: | $this->UUID = $aGroup['UUID']; |
| 49: | } elseif (empty($this->UUID)) { |
| 50: | $this->UUID = \Sabre\DAV\UUIDUtil::getUUID(); |
| 51: | } |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | } |
| 69: | |
| 70: | public function Contacts() |
| 71: | { |
| 72: | return $this->belongsToMany(Contact::class, 'contacts_group_contact', 'GroupId', 'ContactId'); |
| 73: | } |
| 74: | } |
| 75: | |