|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Uxmp\Core\Orm\Model; |
|
6
|
|
|
|
|
7
|
|
|
use DateTimeInterface; |
|
8
|
|
|
use Doctrine\DBAL\Types\Types; |
|
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
10
|
|
|
use Uxmp\Core\Orm\Repository\FavoriteRepository; |
|
11
|
|
|
|
|
12
|
|
|
#[ORM\Entity(repositoryClass: FavoriteRepository::class)] |
|
13
|
|
|
#[ORM\Table(name: 'favorite')] |
|
14
|
|
|
class Favorite implements FavoriteInterface |
|
15
|
|
|
{ |
|
16
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
17
|
|
|
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')] |
|
18
|
|
|
private int $id; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
21
|
|
|
private int $user_id; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
24
|
|
|
private int $item_id; |
|
25
|
|
|
|
|
26
|
|
|
#[ORM\Column(type: Types::STRING, enumType: FavoriteItemTypeEnum::class)] |
|
27
|
|
|
private FavoriteItemTypeEnum $type; |
|
28
|
|
|
|
|
29
|
|
|
#[ORM\Column(type: Types::DATETIME_MUTABLE)] |
|
30
|
|
|
private DateTimeInterface $date; |
|
31
|
|
|
|
|
32
|
|
|
#[ORM\ManyToOne(targetEntity: UserInterface::class)] |
|
33
|
|
|
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] |
|
34
|
|
|
private UserInterface $user; |
|
35
|
|
|
|
|
36
|
1 |
|
public function setUser(UserInterface $user): FavoriteInterface |
|
37
|
|
|
{ |
|
38
|
1 |
|
$this->user = $user; |
|
39
|
1 |
|
return $this; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function getUser(): UserInterface |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->user; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public function setItemId(int $itemId): FavoriteInterface |
|
48
|
|
|
{ |
|
49
|
1 |
|
$this->item_id = $itemId; |
|
50
|
1 |
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
1 |
|
public function getItemId(): int |
|
54
|
|
|
{ |
|
55
|
1 |
|
return $this->item_id; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
1 |
|
public function setType(FavoriteItemTypeEnum $type): FavoriteInterface |
|
59
|
|
|
{ |
|
60
|
1 |
|
$this->type = $type; |
|
61
|
1 |
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
1 |
|
public function getType(): FavoriteItemTypeEnum |
|
65
|
|
|
{ |
|
66
|
1 |
|
return $this->type; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
1 |
|
public function setDate(DateTimeInterface $date): FavoriteInterface |
|
70
|
|
|
{ |
|
71
|
1 |
|
$this->date = $date; |
|
72
|
1 |
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
1 |
|
public function getDate(): DateTimeInterface |
|
76
|
|
|
{ |
|
77
|
1 |
|
return $this->date; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|