Issues (17)

src/Models/Entity/RoleHierarchy.php (2 issues)

Severity
1
<?php
2
3
namespace Potievdev\SlimRbac\Models\Entity;
4
5
use DateTime;
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * RoleHierarchy
10
 *
11
 * @ORM\Table(
12
 *     name="role_hierarchy",
13
 *     uniqueConstraints={@ORM\UniqueConstraint(name="idx_role_hierarchy_unique", columns={"parent_role_id", "child_role_id"})},
14
 *     indexes={
15
 *          @ORM\Index(name="fk_role_hierarchy_child", columns={"child_role_id"}),
16
 *          @ORM\Index(name="fk_role_hierarchy_parent", columns={"parent_role_id"})
17
 *     }
18
 * )
19
 * @ORM\Entity(repositoryClass="Potievdev\SlimRbac\Models\Repository\RoleHierarchyRepository")
20
 * @ORM\HasLifecycleCallbacks
21
 */
22
class RoleHierarchy
23
{
24
    /**
25
     * @var integer
26
     *
27
     * @ORM\Column(name="id", type="integer", nullable=false)
28
     * @ORM\Id
29
     * @ORM\GeneratedValue(strategy="IDENTITY")
30
     */
31
    private $id;
32
33
    /**
34
     * @var DateTime
35
     *
36
     * @ORM\Column(name="created_at", type="datetime", nullable=false)
37
     */
38
    private $createdAt;
39
40
    /**
41
     * @var integer
42
     *
43
     * @ORM\Column(name="parent_role_id", type="integer", nullable=false)
44
     */
45
    private $parentRoleId;
0 ignored issues
show
The private property $parentRoleId is not used, and could be removed.
Loading history...
46
47
    /**
48
     * @var integer
49
     *
50
     * @ORM\Column(name="child_role_id", type="integer", nullable=false)
51
     */
52
    private $childRoleId;
0 ignored issues
show
The private property $childRoleId is not used, and could be removed.
Loading history...
53
54
    /**
55
     * @var Role
56
     *
57
     * @ORM\ManyToOne(targetEntity="Potievdev\SlimRbac\Models\Entity\Role")
58
     * @ORM\JoinColumns({
59
     *   @ORM\JoinColumn(name="child_role_id", referencedColumnName="id")
60
     * })
61
     */
62
    private $childRole;
63
64
    /**
65
     * @var Role
66
     *
67
     * @ORM\ManyToOne(targetEntity="Potievdev\SlimRbac\Models\Entity\Role")
68
     * @ORM\JoinColumns({
69
     *   @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id")
70
     * })
71
     */
72
    private $parentRole;
73
74
    public function getId(): int
75
    {
76
        return $this->id;
77
    }
78
79
    public function setId(int $id)
80
    {
81
        $this->id = $id;
82
    }
83
84
    public function getCreatedAt(): DateTime
85
    {
86
        return $this->createdAt;
87
    }
88
89
    public function setCreatedAt(DateTime $createdAt)
90
    {
91
        $this->createdAt = $createdAt;
92
    }
93
94
    public function getChildRole(): Role
95
    {
96
        return $this->childRole;
97
    }
98
99
    public function setChildRole(Role $childRole)
100
    {
101
        $this->childRole = $childRole;
102
    }
103
104
    public function getParentRole(): Role
105
    {
106
        return $this->parentRole;
107
    }
108
109
    public function setParentRole(Role $parentRole)
110
    {
111
        $this->parentRole = $parentRole;
112
    }
113
114
    /** @ORM\PrePersist */
115
    public function prePersist()
116
    {
117
        $this->createdAt = new DateTime();
118
    }
119
}
120