2020-05-29 13:41:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Model\Entity;
|
|
|
|
|
|
|
|
use App\Model\Entity\AppModel;
|
|
|
|
use Cake\ORM\Entity;
|
|
|
|
|
|
|
|
class Individual extends AppModel
|
|
|
|
{
|
2021-06-28 14:04:01 +02:00
|
|
|
protected $_accessible = [
|
|
|
|
'*' => true,
|
|
|
|
'id' => false,
|
|
|
|
'uuid' => false,
|
2022-01-31 09:35:33 +01:00
|
|
|
'created' => false,
|
2021-06-28 14:04:01 +02:00
|
|
|
];
|
2021-06-28 14:49:38 +02:00
|
|
|
|
|
|
|
protected $_accessibleOnNew = [
|
|
|
|
'uuid' => true,
|
2022-01-31 09:35:33 +01:00
|
|
|
'created' => true,
|
2021-06-28 14:49:38 +02:00
|
|
|
];
|
2021-10-12 10:16:36 +02:00
|
|
|
|
2021-11-03 11:47:10 +01:00
|
|
|
protected $_virtual = ['full_name', 'alternate_emails'];
|
2021-10-12 10:16:36 +02:00
|
|
|
|
|
|
|
protected function _getFullName()
|
|
|
|
{
|
|
|
|
if (empty($this->first_name) && empty($this->last_name)) {
|
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
return sprintf("%s %s", $this->first_name, $this->last_name);
|
|
|
|
}
|
2021-11-03 11:47:10 +01:00
|
|
|
|
|
|
|
protected function _getAlternateEmails()
|
|
|
|
{
|
|
|
|
$emails = [];
|
|
|
|
if (!empty($this->meta_fields)) {
|
|
|
|
foreach ($this->meta_fields as $metaField) {
|
|
|
|
if (str_contains($metaField->field, 'email')) {
|
|
|
|
$emails[] = $metaField;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $emails;
|
|
|
|
}
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|