<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Repository\catRepository;
#[ORM\Entity(repositoryClass: catRepository::class)]
#[ORM\Table(name: "cat", options: ["comment"=> "Catégories utilisateurs"])]
class cat
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
#[ORM\Column(name: "catid", type: "integer", options: ["comment" => "Id catégorie"])]
private $catid;
#[ORM\Column(name: "catlib", type: "string", length: 100, nullable: false, unique: true, options: ["comment"=> "Libellé catégorie"])]
private $catlib;
#[Assert\Range(
min: 0,
max: 128,
notInRangeMessage: 'You must be between {{ min }}cm and {{ max }}cm tall to enter',
)]
#[ORM\Column(name: "catord", type: "smallint", options: ["default"=>1, "comment"=>"Ordre affichage catégories"])]
private $catord;
#[ORM\OneToMany(targetEntity:"usr", mappedBy:"catid", cascade:["persist","remove"], orphanRemoval:true)]
private $usrids;
public function __construct()
{
//parent::__construct();
$this->usrids = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getCatid(): ?int
{
return $this->catid;
}
/**
* Get catlib
*/
public function getCatlib(): ?string
{
return $this->catlib;
}
/**
* Set catlib
*/
public function setCatlib(?string $catlib): static
{
$this->catlib = $catlib;
return $this;
}
/**
* Get catord
*/
public function getCatord(): ?int
{
return $this->catord;
}
/**
* Set catord
*/
public function setCatord(?string $catord): static
{
$this->catord = $catord;
return $this;
}
/*
OneToMany usr
*/
public function getUsrids()
{
return $this->usrids;
}
public function addUsrid(\App\Entity\usr $usrid)
{
$this->usrids[] = $usrid;
$usrid->setcatid($this);
return $this;
}
public function removeUsrid(\App\Entity\usr $usrid)
{
$this->usrids->removeElement($usrid);
}
}