| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | namespace Aurora\Modules\Contacts\Models; |
| 9: | |
| 10: | use Aurora\Modules\Contacts\Enums\StorageType; |
| 11: | use Aurora\System\Classes\Model; |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | class ContactCard extends Model |
| 47: | { |
| 48: | protected $table = 'contacts_cards'; |
| 49: | |
| 50: | public $timestamps = false; |
| 51: | |
| 52: | protected $fillable = [ |
| 53: | 'Id', |
| 54: | 'CardId', |
| 55: | 'AddressBookId', |
| 56: | 'PrimaryEmail', |
| 57: | 'ViewEmail', |
| 58: | 'PersonalEmail', |
| 59: | 'BusinessEmail', |
| 60: | 'OtherEmail', |
| 61: | 'BusinessCompany', |
| 62: | 'FullName', |
| 63: | 'FirstName', |
| 64: | 'LastName', |
| 65: | 'Frequency', |
| 66: | 'IsGroup', |
| 67: | 'Properties' |
| 68: | ]; |
| 69: | |
| 70: | protected $casts = [ |
| 71: | 'Properties' => 'array', |
| 72: | 'Auto' => 'boolean', |
| 73: | 'Shared' => 'boolean', |
| 74: | 'IsTeam' => 'boolean', |
| 75: | ]; |
| 76: | |
| 77: | protected $appends = [ |
| 78: | 'UUID', |
| 79: | 'AgeScore', |
| 80: | 'UserId', |
| 81: | 'Storage', |
| 82: | "DateModified", |
| 83: | "ETag", |
| 84: | 'ViewEmail', |
| 85: | 'Uri', |
| 86: | ]; |
| 87: | |
| 88: | public function getUUIDAttribute() |
| 89: | { |
| 90: | return $this->attributes['UUID']; |
| 91: | } |
| 92: | |
| 93: | public function getAgeScoreAttribute() |
| 94: | { |
| 95: | return round($this->attributes['AgeScore']); |
| 96: | } |
| 97: | |
| 98: | public function getUserIdAttribute() |
| 99: | { |
| 100: | return $this->attributes['UserId']; |
| 101: | } |
| 102: | |
| 103: | public function getStorageAttribute() |
| 104: | { |
| 105: | return $this->attributes['Storage']; |
| 106: | } |
| 107: | |
| 108: | public function getDateModifiedAttribute() |
| 109: | { |
| 110: | return $this->attributes['DateModified']; |
| 111: | } |
| 112: | |
| 113: | public function getETagAttribute() |
| 114: | { |
| 115: | return $this->attributes['ETag']; |
| 116: | } |
| 117: | |
| 118: | public function getUriAttribute() |
| 119: | { |
| 120: | return $this->attributes['Uri']; |
| 121: | } |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | |
| 127: | protected function getViewEmailAttribute() |
| 128: | { |
| 129: | switch ((int) $this->PrimaryEmail) { |
| 130: | default: |
| 131: | case \Aurora\Modules\Contacts\Enums\PrimaryEmail::Personal: |
| 132: | return (string) $this->PersonalEmail; |
| 133: | case \Aurora\Modules\Contacts\Enums\PrimaryEmail::Business: |
| 134: | return (string) $this->BusinessEmail; |
| 135: | case \Aurora\Modules\Contacts\Enums\PrimaryEmail::Other: |
| 136: | return (string) $this->OtherEmail; |
| 137: | } |
| 138: | } |
| 139: | } |
| 140: | |