src/Entity/UserRole.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Table(name="users__users_roles")
  6.  * @ORM\Entity()
  7.  */
  8. class UserRole
  9. {
  10.     const LOGIN 'login';
  11.     const ADMIN 'admin';
  12.     const MANAGER 'manager';
  13.     const LOGIST 'logist';
  14.     const COURIER 'courier';
  15.     const ROLES = [
  16.         self::LOGIN => 'Пользователь',
  17.         self::ADMIN => 'Администратор',
  18.         self::MANAGER => 'Менеджер',
  19.         self::LOGIST => 'Логист',
  20.         self::COURIER => 'Курьер',
  21.     ];
  22.     use IdTrait;
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  25.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  26.      **/
  27.     private User $user;
  28.     /**
  29.      * @ORM\Column(name="role", type="string", nullable=false)
  30.      */
  31.     private string $role;
  32.     public function __construct(User $user$role)
  33.     {
  34.         $this->user $user;
  35.         $this->role $role;
  36.     }
  37.     public function getUser(): User
  38.     {
  39.         return $this->user;
  40.     }
  41.     public function getRole(): string
  42.     {
  43.         return $this->role;
  44.     }
  45. }