blob: c06516c3e38f70581c0e86b72f0a547b786ba26e (
plain)
1
2
3
4
5
6
7
8
9
10
11
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
47
48
49
50
|
<?php
namespace Lti;
use User;
use Avatar;
use SimpleORMap;
/**
* @property int $id
* @property int $mkdate
* @property int $chdate
* @property Publication $publication
* @property User $user
*/
class PublicationUser extends SimpleORMap
{
protected static function configure($config = [])
{
$config['db_table'] = 'lti_publication_users';
$config['belongs_to']['publication'] = [
'class_name' => Publication::class,
'foreign_key' => 'publication_id',
'assoc_foreign_key' => 'id'
];
$config['belongs_to']['user'] = [
'class_name' => User::class,
'foreign_key' => 'user_id',
'assoc_foreign_key' => 'user_id'
];
parent::configure($config);
}
public function transformData(): array
{
return [
...$this->toRawArray(),
'mkdate' => date('c', $this->mkdate),
'chdate' => date('c', $this->chdate),
'user' => $this->user ? [
'id' => $this->user->id,
'name' => $this->user->getFullName(),
'username' => $this->user->username,
'avatar_url' => Avatar::getAvatar($this->user->id)->getURL(Avatar::MEDIUM)
] : []
];
}
}
|