-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserLog.php
79 lines (72 loc) · 1.82 KB
/
UserLog.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
declare(strict_types=1);
namespace ArrayAccess\TrayDigita\App\Modules\Users\Entities;
use ArrayAccess\TrayDigita\Database\Entities\Abstracts\AbstractUserBasedLog;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\ORM\Mapping\Index;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\Table;
#[Entity]
#[Table(
name: self::TABLE_NAME,
options: [
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'comment' => 'Common user logs',
],
)]
#[Index(
name: 'relation_user_logs_user_id_users_id',
columns: ['user_id']
)]
#[Index(
name: 'index_user_id_name_type',
columns: ['user_id', 'name', 'type']
)]
#[HasLifecycleCallbacks]
class UserLog extends AbstractUserBasedLog
{
public const TABLE_NAME = 'user_logs';
#[
JoinColumn(
name: 'user_id',
referencedColumnName: 'id',
nullable: false,
onDelete: 'CASCADE',
options: [
'relation_name' => 'relation_user_logs_user_id_users_id',
'onUpdate' => 'CASCADE',
'onDelete' => 'CASCADE'
]
),
ManyToOne(
targetEntity: User::class,
cascade: [
"persist",
"remove",
// "merge",
"detach"
],
fetch: 'LAZY'
)
]
protected User $user;
/**
* Allow associations mapping
* @see jsonSerialize()
*
* @var bool
*/
protected bool $entityAllowAssociations = true;
public function setUser(User $user): void
{
$this->user = $user;
$this->setUserId($user->getId());
}
public function getUser(): User
{
return $this->user;
}
}