diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 5bbea45..e39ef27 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -89,26 +89,13 @@ } }, "profile_contact_company_job": { - "name": "profile_contact_company_job", + "name": "profile_contact_job", "type": "VARCHAR(255)", "null": false, "annotations": { "gdpr": true } }, - "profile_contact_address": { - "name": "profile_contact_address", - "type": "VARCHAR(255)", - "null": false, - "annotations": { - "gdpr": true - } - }, - "profile_contact_website": { - "name": "profile_contact_website", - "type": "VARCHAR(255)", - "null": false - }, "profile_contact_birthday": { "name": "profile_contact_birthday", "type": "DATETIME", @@ -164,44 +151,89 @@ "type": "TINYINT", "null": false }, + "profile_contact_element_order": { + "name": "profile_contact_element_order", + "type": "INT", + "null": false + }, "profile_contact_element_content": { "name": "profile_contact_element_content", "type": "VARCHAR(255)", "null": false - }, - "profile_contact_element_contact": { - "name": "profile_contact_element_contact", - "type": "INT", - "null": false, - "foreignTable": "profile_contact", - "foreignKey": "profile_contact_id" } } }, - "profile_contact_address": { - "name": "profile_contact_address", + "profile_contact_elementrel": { + "name": "profile_contact_elementrel", "fields": { - "profile_contact_address_id": { - "name": "profile_contact_address_id", + "profile_contact_elementrel_id": { + "name": "profile_contact_elementrel_id", "type": "INT", "null": false, "primary": true, "autoincrement": true }, - "profile_contact_address_type": { - "name": "profile_contact_address_type", - "type": "TINYINT", - "null": false - }, - "profile_contact_address_contact": { - "name": "profile_contact_address_contact", + "profile_contact_elementrel_contact": { + "name": "profile_contact_elementrel_contact", "type": "INT", "null": false, "foreignTable": "profile_contact", "foreignKey": "profile_contact_id" }, - "profile_contact_address_address": { - "name": "profile_contact_address_address", + "profile_contact_elementrel_element": { + "name": "profile_contact_elementrel_element", + "type": "INT", + "null": false, + "foreignTable": "profile_contact_element", + "foreignKey": "profile_contact_element_id" + } + } + }, + "profile_contactelementrel": { + "name": "profile_contactelementrel", + "fields": { + "profile_contactelementrel_id": { + "name": "profile_contactelementrel_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "profile_contactelementrel_profile": { + "name": "profile_contactelementrel_profile", + "type": "INT", + "null": false, + "foreignTable": "profile_account", + "foreignKey": "profile_account_id" + }, + "profile_contactelementrel_element": { + "name": "profile_contactelementrel_element", + "type": "INT", + "null": false, + "foreignTable": "profile_contact_element", + "foreignKey": "profile_contact_element_id" + } + } + }, + "profile_contact_addressrel": { + "name": "profile_contact_addressrel", + "fields": { + "profile_contact_addressrel_id": { + "name": "profile_contact_addressrel_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "profile_contact_addressrel_contact": { + "name": "profile_contact_addressrel_contact", + "type": "INT", + "null": false, + "foreignTable": "profile_contact", + "foreignKey": "profile_contact_id" + }, + "profile_contact_addressrel_address": { + "name": "profile_contact_addressrel_address", "type": "INT", "null": false, "foreignTable": "address", @@ -209,65 +241,25 @@ } } }, - "profile_contactelement": { - "name": "profile_contactelement", - "comment": "email, phone etc for profiles", + "profile_addressrel": { + "name": "profile_addressrel", "fields": { - "profile_contactelement_id": { - "name": "profile_contactelement_id", + "profile_addressrel_id": { + "name": "profile_addressrel_id", "type": "INT", "null": false, "primary": true, "autoincrement": true }, - "profile_contactelement_type": { - "name": "profile_contactelement_type", - "type": "TINYINT", - "null": false - }, - "profile_contactelement_subtype": { - "name": "profile_contactelement_subtype", - "type": "TINYINT", - "null": false - }, - "profile_contactelement_content": { - "name": "profile_contactelement_content", - "type": "VARCHAR(255)", - "null": false - }, - "profile_contactelement_contact": { - "name": "profile_contactelement_contact", - "type": "INT", - "null": false, - "foreignTable": "profile_account", - "foreignKey": "profile_account_id" - } - } - }, - "profile_address": { - "name": "profile_address", - "fields": { - "profile_address_id": { - "name": "profile_address_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "profile_address_type": { - "name": "profile_address_type", - "type": "TINYINT", - "null": false - }, - "profile_address_profile": { - "name": "profile_address_profile", + "profile_addressrel_profile": { + "name": "profile_addressrel_profile", "type": "INT", "null": false, "foreignTable": "profile_account", "foreignKey": "profile_account_id" }, - "profile_address_address": { - "name": "profile_address_address", + "profile_addressrel_address": { + "name": "profile_addressrel_address", "type": "INT", "null": false, "foreignTable": "address", diff --git a/Models/Contact.php b/Models/Contact.php new file mode 100644 index 0000000..a9320bf --- /dev/null +++ b/Models/Contact.php @@ -0,0 +1,109 @@ +image = new NullMedia(); + } + + public function getId() : int + { + return $this->id; + } + + public function getName1() : string + { + return $this->name1; + } + + public function setName1(string $name) : void + { + $this->name1 = $name; + } + + public function getName2() : string + { + return $this->name2; + } + + public function setName2(string $name) : void + { + $this->name2 = $name; + } + + public function getName3() : string + { + return $this->name3; + } + + public function setName3(string $name) : void + { + $this->name3 = $name; + } + + public function getDescription() : string + { + return $this->description; + } + + public function setDescription(string $description) : void + { + $this->description = $description; + } + + public function setImage(Media $image) : void + { + $this->image = $image; + } + + public function getImage() : Media + { + return $this->image; + } +} diff --git a/Models/ContactElement.php b/Models/ContactElement.php index 3b97c91..e261601 100755 --- a/Models/ContactElement.php +++ b/Models/ContactElement.php @@ -40,6 +40,14 @@ class ContactElement */ private int $type = 0; + /** + * Contact element subtype. + * + * @var int + * @since 1.0.0 + */ + private int $subtype = 0; + /** * Content. * @@ -48,6 +56,14 @@ class ContactElement */ private string $content = ''; + /** + * Order. + * + * @var string + * @since 1.0.0 + */ + private int $order = 0; + /** * Get id. * @@ -86,6 +102,58 @@ class ContactElement return $this->type; } + /** + * Set order + * + * @param int $order Type + * + * @return void + * + * @since 1.0.0 + */ + public function setOrder(int $order) : void + { + $this->order = $order; + } + + /** + * Get order + * + * @return int + * + * @since 1.0.0 + */ + public function getOrder() : int + { + return $this->order; + } + + /** + * Set subtype + * + * @param int $subtype Subtype + * + * @return void + * + * @since 1.0.0 + */ + public function setSubtype(int $subtype) : void + { + $this->subtype = $subtype; + } + + /** + * Get subtype + * + * @return int + * + * @since 1.0.0 + */ + public function getSubtype() : int + { + return $this->subtype; + } + /** * Get content * diff --git a/Models/ContactElementMapper.php b/Models/ContactElementMapper.php index 743d8bc..dad2aaf 100755 --- a/Models/ContactElementMapper.php +++ b/Models/ContactElementMapper.php @@ -33,7 +33,11 @@ final class ContactElementMapper extends DataMapperAbstract * @since 1.0.0 */ protected static array $columns = [ - 'profile_contactelement_id' => ['name' => 'profile_contactelement_id', 'type' => 'int', 'internal' => 'id'], + 'profile_contact_element_id' => ['name' => 'profile_contact_element_id', 'type' => 'int', 'internal' => 'id'], + 'profile_contact_element_type' => ['name' => 'profile_contact_element_type', 'type' => 'int', 'internal' => 'type'], + 'profile_contact_element_subtype' => ['name' => 'profile_contact_element_subtype', 'type' => 'int', 'internal' => 'subtype'], + 'profile_contact_element_order' => ['name' => 'profile_contact_element_order', 'type' => 'int', 'internal' => 'order'], + 'profile_contact_element_content' => ['name' => 'profile_contact_element_content', 'type' => 'string', 'internal' => 'content'], ]; /** @@ -42,7 +46,7 @@ final class ContactElementMapper extends DataMapperAbstract * @var string * @since 1.0.0 */ - protected static string $table = 'profile_contactelement'; + protected static string $table = 'profile_contact_element'; /** * Primary field name. @@ -50,5 +54,5 @@ final class ContactElementMapper extends DataMapperAbstract * @var string * @since 1.0.0 */ - protected static string $primaryField = 'profile_contactelement_id'; + protected static string $primaryField = 'profile_contact_element_id'; } diff --git a/Models/ContactMapper.php b/Models/ContactMapper.php new file mode 100644 index 0000000..70e6855 --- /dev/null +++ b/Models/ContactMapper.php @@ -0,0 +1,75 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'profile_contact_id' => ['name' => 'profile_contact_id', 'type' => 'int', 'internal' => 'id'], + 'profile_contact_name1' => ['name' => 'profile_contact_name1', 'type' => 'string', 'internal' => 'name1'], + 'profile_contact_name2' => ['name' => 'profile_contact_name2', 'type' => 'string', 'internal' => 'name2'], + 'profile_contact_name3' => ['name' => 'profile_contact_name3', 'type' => 'string', 'internal' => 'name3'], + 'profile_contact_description' => ['name' => 'profile_contact_description', 'type' => 'string', 'internal' => 'description'], + 'profile_contact_company' => ['name' => 'profile_contact_company', 'type' => 'string', 'internal' => 'company'], + 'profile_contact_job' => ['name' => 'profile_contact_job', 'type' => 'string', 'internal' => 'job'], + 'profile_contact_birthday' => ['name' => 'profile_contact_birthday', 'type' => 'DateTime', 'internal' => 'birthday'], + 'profile_contact_profile' => ['name' => 'profile_contact_profile', 'type' => 'int', 'internal' => 'profile'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $ownsOne = [ + 'image' => [ + 'mapper' => MediaMapper::class, + 'self' => 'profile_contact_image', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'profile_contact'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'profile_contact_id'; +} diff --git a/Models/ContactType.php b/Models/ContactType.php new file mode 100644 index 0000000..51e8d55 --- /dev/null +++ b/Models/ContactType.php @@ -0,0 +1,36 @@ + [ 'mapper' => AddressMapper::class, - 'table' => 'profile_address', - 'external' => 'profile_address_address', - 'self' => 'profile_address_profile', + 'table' => 'profile_addressrel', + 'external' => 'profile_addressrel_address', + 'self' => 'profile_addressrel_profile', ], 'contactElements' => [ 'mapper' => ContactElementMapper::class, - 'table' => 'profile_contactelement', - 'self' => null, - 'external' => 'profile_contactelement_contact', + 'table' => 'profile_contactelementrel', + 'self' => 'profile_contactelementrel_element', + 'external' => 'profile_contactelementrel_profile', ], ];