mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-01-24 13:38:40 +00:00
implement todos
This commit is contained in:
parent
8b6143194e
commit
50cb1b2a6f
|
|
@ -167,5 +167,31 @@
|
|||
"foreignKey": "account_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"calendar_event_tag": {
|
||||
"name": "calendar_event_tag",
|
||||
"fields": {
|
||||
"calendar_event_tag_id": {
|
||||
"name": "calendar_event_tag_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"calendar_event_tag_src": {
|
||||
"name": "calendar_event_tag_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "calendar_event",
|
||||
"foreignKey": "calendar_event_id"
|
||||
},
|
||||
"calendar_event_tag_dst": {
|
||||
"name": "calendar_event_tag_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "tag",
|
||||
"foreignKey": "tag_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Docs/Dev/img/er.png
Normal file
BIN
Docs/Dev/img/er.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 128 KiB |
|
|
@ -17,6 +17,8 @@ namespace Modules\Calendar\Models;
|
|||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Stdlib\Base\Location;
|
||||
use Modules\Tag\Models\NullTag;
|
||||
use Modules\Tag\Models\Tag;
|
||||
|
||||
/**
|
||||
* Event class.
|
||||
|
|
@ -120,6 +122,14 @@ class Event
|
|||
*/
|
||||
private array $people = [];
|
||||
|
||||
/**
|
||||
* Tags.
|
||||
*
|
||||
* @var Tag[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $tags = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -298,4 +308,70 @@ class Event
|
|||
{
|
||||
return $this->schedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding new tag.
|
||||
*
|
||||
* @param Tag $tag Tag
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addTag(Tag $tag) : int
|
||||
{
|
||||
$this->tags[] = $tag;
|
||||
|
||||
\end($this->tags);
|
||||
$key = (int) \key($this->tags);
|
||||
\reset($this->tags);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Tag from list.
|
||||
*
|
||||
* @param int $id Tag
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function removeTag($id) : bool
|
||||
{
|
||||
if (isset($this->tags[$id])) {
|
||||
unset($this->tags[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task elements.
|
||||
*
|
||||
* @return Tag[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTags() : array
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task elements.
|
||||
*
|
||||
* @param int $id Element id
|
||||
*
|
||||
* @return Tag
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTag(int $id) : Tag
|
||||
{
|
||||
return $this->tags[$id] ?? new NullTag();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace Modules\Calendar\Models;
|
|||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use Modules\Tag\Models\TagMapper;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
|
|
@ -72,6 +73,21 @@ final class EventMapper extends DataMapperAbstract
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
'tags' => [
|
||||
'mapper' => TagMapper::class,
|
||||
'table' => 'calendar_event_tag',
|
||||
'external' => 'calendar_event_tag_dst',
|
||||
'self' => 'calendar_event_tag_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user