59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Enums\CaseLevel;
|
|
use App\Repository\UserCaseRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: UserCaseRepository::class)]
|
|
class UserCase
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'userCases')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?User $user = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'userCases')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?MemberCase $memberCase = null;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUser(): ?User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function setUser(?User $user): static
|
|
{
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getMemberCase(): ?MemberCase
|
|
{
|
|
return $this->memberCase;
|
|
}
|
|
|
|
public function setMemberCase(?MemberCase $memberCase): static
|
|
{
|
|
$this->memberCase = $memberCase;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public static function checkLevel(User $user, MemberCase $case): bool
|
|
{
|
|
return ($user->getLevel()->value >= $case->getLevel()->value);
|
|
}
|
|
}
|